I'm currently working on an ASP.NET MVC 4.5 application. I use Entity Framework 6.
I want to compare 2 lists and add/remove the difference to my collection using Entity Framework 6. I'm looking for a way to get the new items from currentList and add them to the originalList afterwards. My C# looks as follows:
var originalOffer = MyDb.Offer.First(o => o.OfferId == model.OfferId);
if (originalOffer.OfferData.DeliveryModelPool.Delivery.Count > 0)
{
var currentList = model.DeliveryModelId.Select(x => new Delivery {DeliveryModelId = x}).ToList();
var originalList = originalOffer.OfferData.DeliveryModelPool.Delivery.ToList();
//... originalOffer.OfferData.DeliveryModelPool.Delivery. Add or delete the difference here
}
MyDb.SaveChanges();
Do you have an idea on how to solve this issue with EF 6?
Thanks a lot!