Entity Framework, List of List possible?
I wonder if the following is possible to realize with EF 6.0 in C#.
So I have an entity A which has a dict with entities of type B as key and
a list of C entities as value:
public class A
{
public int AID { get; set; }
public Dictionary<B, List<C>> myList { get; set; }
public somePrimitive AdditionalPropertyOfA { get; set; }
public somePrimitive AnotherPropertyOfA { get; set; }
}
I would like to transform this into a database table A, which looks like
the following example:
Table A
AID BID CID AdditionalPropertyOfA ...
1 1 1 ...
1 1 2 ...
1 2 3 ...
1 2 4 ...
2 1 1 ...
2 2 2 ...
2 2 3 ...
2 2 4 ...
So I hope it gets clear what I mean. In the above example we would have
two A entities, two B entities and four C entities.
For A=1 we have: B=1: 1->2 and B=2: 3->4
For A=2 we have: B=1: 1 and B=2: 2->3->4
The problem is that I have no idea how to write this in the entity class A
or with the fluent Api. Class A needs to have a n:m mapping to entity B
and also needs a n:m mapping to C. But how to bring these things together?
Edit: To make it more clear what I mean: Think of A's as work plans, B's
as employees and C's as tasks for the employees. The B's are entities on
their own (name, address, etc.), but within the context of A they have
assigned tasks.
No comments:
Post a Comment