3
votes

Lets say we are using DTO objects to transfer data between service layer and Presentation (MVC) layer.In this case the presentation layer can only access DTO objects. Therefore we can't use lazy loading functionality in Entity framework. Am I right here? Please give your suggestions.

(My DTO are not the entities in EF and I have implemented repository and unit of work pattern)

2

2 Answers

2
votes

You can use lazy loading but only on your service side when you are working with attached entities.

1
votes

First put your definition right: Are your DTO objects also your entities in EF 4.1? Are they (also) your models and do they contain business logic?

If so, i would recommend turning off proxy creation ( myDbContext.Configuration.ProxyCreationEnabled = false; ) since they cant be serialized easily. Then use a repository for dataAccess where in the CRUD methods, you specify the right entity states like: http://blogs.msdn.com/b/adonet/archive/2011/01/29/using-dbcontext-in-ef-feature-ctp5-part-4-add-attach-and-entity-states.aspx