How to assign the EntityCollection property to another property?

I have a type that is derived from the Entity generated by the Entity Framework 3. How do I assign a single Customer Order property to the Derived Customer Order property?

derivedCustomer.Orders = customer.Orders

I am not trying to change orders; this is just an example of what I'm trying to achieve. Has anyone tried this and succeeded?

+3
source share
1 answer

Scroll through each entry and add to another collection:

foreach (var order in customer.Orders)
   derivedCustomer.Orders.Add(order);

You can also make the extension method to make it seamless as well.

+1
source

Source: https://habr.com/ru/post/1775771/


All Articles