Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I assign EntityCollection property to another property?

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

derivedCustomer.Orders = customer.Orders

I'm not actually trying to swap orders; this is just an example of what I am trying to achieve. Has anyone done tried this and succeed?

like image 457
Moderator71 Avatar asked Dec 10 '25 08:12

Moderator71


1 Answers

Loop through each record and add to the other collection:

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

You could make an extension method to make that seamless too.

like image 184
Brian Mains Avatar answered Dec 11 '25 21:12

Brian Mains



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!