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?

4

1 回答 1

1

您可以使用 AutoMapper 之类的技术将 LINQ to SQL 对象复制到业务层中的业务对象中。根据您的场景,您可以将另一层数据传输对象传递回客户端。您可以再次使用 AutoMapper 将适当的属性从业务对象复制到 DTO 对象。

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

http://automapper.codeplex.com/

于 2010-08-02T16:01:36.603 回答