UPDATE2. Eventually I solved the problem by just setting all navigation properties to null for the lineItem.
UPDATE. Went ahead and implemented the Clone method in the partial class of my model. I wish the Reversed POCO generator had this method already, although we can probably add it as well.
For now I just did it for a particular class where I needed it. Will test now.
Hi everybody,
This is the continuation of my previous question. I think I need to create a copy of the line item in order to add it to the duplicated purchase order. I did some search in stackoverflow and found few blogs on the topic one of them being by Rick Strahl
https://weblog.west-wind.com/posts/2009/Aug/04/Simplistic-Object-Copying-in-NETand the other is
https://actualrandy.wordpress.com/2015/01/17/copying-with-automapper-and-memberwiseclone/So, in my code I'm now trying:
foreach(IPchord lineItem in purchaseOrdersViewModel.LineItems)
{
IPchord newLineItem = lineItem.MemberwiseClone();
but this produces an error in compile time:
cannot access protected member via a qualifier ...
So, I'm not sure how should I proceed here. I want a copy of that object (only simple properties).
Thanks a lot in advance.
If it's not broken, fix it until it is.
My Blog