.Remove(object) on a List<T> returned from LINQ to SQL compiled query won't delete the Object right
Posted
by soldieraman
on Stack Overflow
See other posts from Stack Overflow
or by soldieraman
Published on 2010-06-12T02:12:42Z
Indexed on
2010/06/12
2:22 UTC
Read the original article
Hit count: 300
I am returning two lists from the database using LINQ to SQL compiled query.
While looping the first list I remove duplicates from the second list as I dont want to process already existing objects again.
eg.
//oldCustomers is a List returned by my Compiled Linq to SQL Statmenet that I have added a .ToList() at the end to
//Same goes for newCustomers
for (Customer oC in oldCustomers)
{
//Do some processing
newCustomers.Remove(newCusomters.Find(nC=> nC.CustomerID == oC.CusomterID));
}
for (Cusomter nC in newCustomers)
{
//Do some processing
}
DataContext.SubmitChanges()
I expect this to only save the changes that have been made to the customers in my processing and not Remove or Delete any of my customers from the database.
Correct?
I have tried it and it works fine - but I am trying to know if there is any rare case it might actually get removed
© Stack Overflow or respective owner