A1 |__A2 |__A3 |__A4 |__A5 B1 |__B2 |__B3 |__B4 |__B5 C1 |__C2 |__C3 |__C4 |__C5
Given a list of A and a list of B, we want to "join" the two and put the results into C. The join should include everything from A and B, and indicate with a derived field whether its in A or B. It's this joined list that would be persisted into C.
Note: Each of these lists represent sql tables and the corresponding entities and their FK relations. Each table has more or less the same fields with the same datatypes. The difference however, is that some records will be in A but not in B, some in both etc.
My approach: Create a list of POCO classes that each list of A and B are selected and projected into. Then using LINQ (linq to objects, not linq to ef in this case), since we now simply would have two lists of objects. Join these lists into a new list. Select from this list, creating our destination entities, C. Finally, call savechanges to persist to the Db.
Assuming the problem is clear enough - is there a better approach or design pattern I can tap into that addresses this problem?
[ update ]
In other words, I am planning to join (eg. link ) the two lists together into a result list. From this result, I will project the results into a new list that represent the destination entities. Once that destination list is created. I should be able to simply add to the DbContext and call save changes.