none
Model First Composite Pattern RRS feed

  • Question

  • Hey Guys,

    I am using EF 6.1 and i need to implement a composite pattern. I am new with working with EF and i wanted to ask if anybody could give me some support.

    I do not want to use Code First because at work we always use Model First Approach.

    Would be great if someone could help me out with some examples and show me how it could use LazyLoading to load a component from the composite pattern and EF.

    Thanks a lot for the support

    Franklin

    Wednesday, June 11, 2014 1:04 PM

All replies

  • Wednesday, June 11, 2014 2:12 PM
  • Thank you David for the reply..

    I checked out your link. I know how to create the model but i am not sure how to model the Composite Pattern so that i can use it with entity framework the best way...

    any hints on that....?

    Wednesday, June 11, 2014 2:55 PM
  • Can you describe the domain you're trying to model?

    David


    David http://blogs.msdn.com/b/dbrowne/

    Wednesday, June 11, 2014 3:27 PM
  • Thanks for the fast reply...

    Currently my account is not yet verified so i need to describe it rather than putting a nice class diagram here...

    But what i want is to create a standard Composite Pattern with a Abstract Component, Unit class that implements the IEnumerable<Component> and a Part class.

    Then i can create a new Unit, for example a Car with a Motor as a Unit and so on until i only have parts.

    Would i create the same data model in the EF Designer or is there a different approach? And is it possible to get a Unit and load all its SubUnits an Items (Lazy Loading)? For example get the car and then go through all units of the car?

    I appreciate the help, hope my explaining is clear enough :-/


    Wednesday, June 11, 2014 5:25 PM
  • I'm not sure. Perhaps you should start with a C# class model of the domain.

    David


    David http://blogs.msdn.com/b/dbrowne/

    Wednesday, June 11, 2014 6:32 PM
  • Hello,

    >>And is it possible to get a Unit and load all its SubUnits an Items (Lazy Loading)? For example get the car and then go through all units of the car?

    Yes, Entity Framework is lazy loading by default. For details, see here.

    Since you cannot upload the picture, I would like suggest you providing some code regarding your model so that we can know what you want exactly as David said.

    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.

    Thursday, June 12, 2014 3:07 AM
    Moderator