none
Entity framework and Eager loading and enterprise application with DDD aproach RRS feed

  • Question


  • In the name of Allah

    Hello sir/madam

    We are trying to create an ASP.NET MVC 4 application using entity framework with domain driven development style pattern approach. As you can see in our part of domain layer, we have a complex design. We need to load entity with lazy and eager methods. Unfortunately we have big problem with these methods in entity framework. As we understood for eager loading in EF we have to use include method and give string of properties and properties of properties and etc. (In Hibernate and java we could use annotation top of member to load eager and it was so easier than this approach) but are horrible problem is when we have inheritances structure and heavy polymorphism, in these states we don’t have that’s string we should write after include because we don’t know which derived class of class is selected to understand which properties should include.

     

    For example as you can see result has a collection of items and then consider add some group to this collection and each of those groups have some groups and fields (like composition pattern), now imagine we want to load a result is like talked above. When I want to write string of given include I don’t know that items of this result are groups. Because we can’t predict these items are groups and so these groups have collection of items which should load.

    this.Items = new List<Item> 
                 {
                     new Group(
                         a,
                         new List<Item>
                         { 
                             new Field(b),
                             new Field(c),
                             new Field(d),

    At last we have a critical question: is entity framework designed for Enterprise Application with complex domain and DDD approach? If not how we follow approach of Martin Fowler and Eric Evans in software engineering and enterprise application in C#?    

    Thursday, November 14, 2013 9:01 PM

Answers

  • Hello,

    >>At last we have a critical question: is entity framework designed for Enterprise Application with complex domain and DDD approach?

    Yes, it should be the code first model in entity framework.

    Please have a look at the article:

    http://msdn.microsoft.com/en-us/magazine/jj883952.aspx

    It introduces us to a concept from domain-driven design (DDD)—Bounded Context—and show us how to apply it to build a targeted model with EF, focusing on doing this with the greater flexibility of the EF Code First feature.

    Regards.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Saturday, November 16, 2013 2:26 AM
    Moderator