Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
wwb
Aug 17, 2004

Why scrape the html when just about everything in sharepoint should be exposed in a web service which is a bit less work to consume . . .

Adbot
ADBOT LOVES YOU

wwb
Aug 17, 2004

Dr. Poz posted:

It's Friday. Let's have a fight: I've seen some support here and other places in favor of using Query objects to encapsulate data access (EF, NHibernate, Raven, etc) and I tried pulling up a few examples and working out a rough example for a particular itch at work I've wanted scratched. I showed it to a coworker and his concern was that he was seeing the dreaded Repository pattern being called by another name. I can see the argument for it, I suppose. The thing I'm working on really isn't of any consequence, so this may not be the best project to use in the search of a specific answer since the nature of the project can dictate the approach to take but I'm interested in the experiences by those here. For this project, my only real needs are querying the data

What separates the two in your minds? Is this a difference without a distinction? Does the name you call it by not matter? Are they both Anti-Patterns?

Here are some links I looked over while researching.

Query Objects: a better approach than your BLL/repository

https://lostechies.com/jimmybogard/2012/10/08/favor-query-objects-over-repositories/

Well designed query commands and/or specifications

I think there is a big difference -- you can create very, very flexible yet targeted query objects versus the very generic things one gets to see in repositories. At the same time, if you hit the upstream interfaces right, you can keep a lot of the flexibility you get by riding generic repositories. One trick I really loved with it was using the query objects to perform inversion of control in certain places. I would definitely use it again.

Now, I do agree that you need to be careful not to twist the query object pattern into generic repository land. That is what happened when I handed the project to one of our junior guys.

wwb
Aug 17, 2004

EssOEss posted:

That style you have there is perfectly normal and is a fine way to do it. Yes, the constructors will be long and you will have private fields. Don't worry about it - that is how it is meant to be. Make sure you are making proper use of a dependency injection container to remove any manual labor involved in wiring up the dependencies - you should not be calling any of these constructors manually.

Most dependency injection containers should also allow properties to be injected into, allowing you to remove the constructors, if that makes you like the look of the code better. I personally can't stand it since it requires the setters to be open to calling also later, which is just evil.

I think constructor injection vs property injection is an important semantic point. Constructor injection says "I need this to operate and there is no sensible default so you must supply this info" whereas property injection is a case where a sensible default can be found and you can just run with it. A good simple example would be a logger -- I'd give an object a default implementation that either is just eating the messages or spitting out debug output and then let folks inject fancier ones for production.

wwb
Aug 17, 2004

Malcolm XML posted:

loading data into sql server with dupe detection can and should be done in 1-2 statements (create temp or CTE on a merge into and log matches)

god knows what's going on inside EF to generate the row tuple.

This. Or if you need fancier than you want to do in sql just use ADO.NET or dapper if you are too cool for raw sql.

Faldoncow posted:

For hosting ASP.Net Web API 2, I know I can use IIS and apparently I can have it self-host with OWIN. Is there any major advantages to IIS or issues with self-hosting with OWIN? This is on a Windows Embedded system, if that makes any difference.

Self-hosted probably makes sense there. IIS is great if you need public-facing, hardened, internet ready stuff and/or managability. But self-hosting is great for internal app APIs and IoT poo poo.

wwb
Aug 17, 2004

Or preferring linux.

Sitepoint just did an article on it which might be a good starting point.

wwb
Aug 17, 2004

The bogeyman in the angular room is Angular 2.0 which will break your 1.3 apps pretty bad.

@UberJumper -- we consumed many APIs before all this HttpClient hoo-ha. In fact, you could argue that HttpClient is really a bad port of RestSharp on some levels. Check that out, it should handle most API client tasks and there are 4.0 compatible versions about.

wwb
Aug 17, 2004

RICHUNCLEPENNYBAGS posted:

Do any of you guys do JS-heavy projects? I'm working on some Angular/WebAPI stuff and I prefer doing the client-side stuff in WebStorm over Visual Studio but it's a real hassle keeping the csproj in sync with all the files on disk (which is necessary because if you don't it breaks csproj-based publishing, which we're using for deployment). Is there any good way to handle this?

A dumb trick I've used from time to time is to use the old .csproj less website projects to contain the assets which stays out of vs' hair. For publishing we just had a custom msbuild script that copied the entire static assets folder as appropriate.

There are better ways to do this in the modern world though.

wwb
Aug 17, 2004

This is probably a routing issue. I'd start with the route debugger -- see http://blogs.msdn.com/b/webdev/archive/2013/04/04/debugging-asp-net-web-api-with-route-debugger.aspx for a start.

wwb
Aug 17, 2004

Yup, declared on controller routes are pretty much the way to go.

I remember when MVC first came out and people didn't even realize you could have routes besides controller/action/id for a few years. I had to beat that one into people's heads . . .

wwb
Aug 17, 2004

Essential posted:

Has anyone created Task Scheduler jobs from code? It looks like it's possible from a command line. Another option seems to be to export as a file and then copy it into the correct folder.

I need something that works from XP on up. Is there any libraries recommended?

edit: found this, https://taskscheduler.codeplex.com/ That looks pretty good and is available via Nuget.

FWIW we have moved most things that we triggered via scheduled tasks into the app as Quartz.NET jobs. Self contained is cool.

wwb
Aug 17, 2004

Thanks for clarifying the use case. Quartz.net probably isn't suitable here -- it is an internal scheduler which presumes your app is running not something that can get your app running like you need.

wwb
Aug 17, 2004

EssOEss posted:

As someone who has worked for a .NET CMS maker, all .NET CMSes are poo poo. You're better off using Wordpress.

This.

I've made more .NET CMS apps than any sane person should because there is nothing out there. These days we let the hippies use wordpress as the front end and feed them stuff via web APIs when we have data that matters.

Adbot
ADBOT LOVES YOU

wwb
Aug 17, 2004

epalm posted:

I keep running into the same ASP problem.

Generally my ASP solutions are structured like this:
  • FooAsp
  • FooCore
  • FooCore.Tests

FooCore is "The Application".

FooAsp is pretty thin, and depends on FooCore to get the real work done. If I wanted to, I could write other interfaces like FooConsole or FooWpf.

FooCore.Tests, as expected, depends on FooCore and runs my tests.

I want to take advantage of user management via the Identity framework, which does registration, login, password hashing, password resets, authorization via roles, authentication via cookies (mvc) and tokens (webapi), and more. I really, really don't want to write and maintain these things myself. However, the ApplicationUser class is sitting in a UserContext in FooAsp, and all my other entities are sitting in DataContext in FooCore.

Here's an example of the problem. Say I wanted to add a feature that sends users text messages based on events that occur in FooCore. I want to build a testable class in FooCore that interfaces with (for example) Twilio, with restrictions on how many messages per second it sends, logs who it has sent messages to, records failures, etc. FooCore doesn't know about FooAsp (ie doesn't know about ApplicationUser).

What I've done in the past is write my own User entity in FooCore that maps 1:1 with an ApplicationUser in FooAsp, but this is a pain to keep synchronized (and redundant to keep two user tables in literally the same database).

How can I deal with this properly?

Personally I would typically render unto the framework what is the framework and keep my own copy of the user data I cared about. There might end up being minimal duplication of data as the framework might need email for mechanical purposes and I'd need email for marketing purposes but I'd rather control my data and be able to use it without needing to keep the same tables working with the framework's mechanics. The bridge I used to use was a ProviderUserKey setting under the old membership stuff, I'd suspect there is an equivalent in the new Identity stuff but I haven't been down that path recently.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply