views:

44

answers:

1

When thinking about traditional layered application design, I often think in terms of 3 layers:

  • The bottom-most layer which actually talks to the database (let's call this the "data access layer"). It returns objects (in some form) to the next layer.
  • The layer above the bottom-most layer (the middle layer, which I'll term the "data layer") takes the objects from the data access layer and returns domain objects to the business layer.
  • The business layer takes the domain objects from the data layer and does things with them.

This is certainly an over-simplified explanation and probably incredibly wrong! :)

Obviously with LINQ to SQL being an ORM, the data access layer is creating LINQ to SQL objects. What is the proper pattern for passing these objects to the middle and top layers?

+1  A: 

You can use a technology like AutoMapper to copy your LINQ to SQL Objects into your Business Objects in your business tier. Depending on your scenario you can have another layer of Data Transfer Objects that you pass back to the client. You can once again use AutoMapper to copy the appropriate properties from the Business Objects to the DTO objects.

http://en.wikipedia.org/wiki/Data_transfer_object

http://automapper.codeplex.com/

KenB