views:

149

answers:

4

I am building a c# - linq - sql server winforms/asp.net application, accessing a database. I would like my business logic layer to be easily testable, and that means not littering it with Linq database queries everywhere. What design patterns/ best practices are available for the following use cases - inserting/updating a new object - searching for an object - loading a bunch of related data into a sort of "presentation" object that could be displayed by various views ?

+1  A: 

I recomend to view video lessons http://www.asp.net/mvc/videos#ASP.NET%20MVC%20Storefront%20Starter%20Kit Part 1-3 about services/repositories/filters. It's good solution.

Maksim Kondratyuk
+1  A: 

Look into putting your database calls into a set of classes implementing a common interface (Repository pattern is a common way to do this). Then you can mock these objects when running tests. Just make sure the repositories themselves are tested somewhere too :)

AlexCuse
+1  A: 

The Repository Pattern is the one I think you're looking for

pdr
+2  A: 

Here is a six part article about Architecting LINQ To SQL Applications

Giorgi