开发者

How do I assign EntityCollection property to another property?

开发者 https://www.devze.com 2023-01-25 16:50 出处:网络
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?

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.Orde开发者_JAVA技巧rs = 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?


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消