I am an Entity Model 4.0 newbie. I have an entity model setup that was created by modeling an SQL database. I can use the model's basic capabilities - query tables, update tables, join and select, etc.
Imagine we have the following DB structure.
It is very easy to create a Parent object or a Child object using the model's Entity Object types and poplulate those objects from the DB using a linq query.
What I want is a combined object that has both the Parent and Child info in one object where the parent child relationship is maintained.
One way to do this is as follows:
pubilc class CombinedObject
public Parent ParentObject;
public Child Child Object;
CombinedObject object = new CombinedObject()
Parent object.ParentObject = new Parent()
Child object.ChildObject = new Child()
List<object> ParentsAndChildren = new List<object>
Now we can populate ParentsAndChildren with a linq Query joining Child to Parent and looping through the results adding each joined record to the list appropriately. This will create one ParentsAndChildren list item for each Child record. The Parent information would be repeated. You could avoid this by having the ChildObject in inside the class be a list.
Creating this object outside of the Entity Model seems to be repetive. The model should already have a way to store the combined objects becuase it already understands the Parent/Child relationship.
Is there a better way to create the combined Parent/Child object. Imagine an application that is going to read the entire DB into a business object that is structred just like the DB.