Having issues with Save not working and looking for most efficient methodology.
If I do this inside the loop it works, but is super slow:
var entity = dbContext.customer.find(fubar.id);
dbContext.Entry(entity).CurrentValues.SetValues(fubar);
Here is the code
var myCollection = dbContext.customer.where(...);
foreach (var fubar in myCollection.where(x => x.addressId == null))
{
var existingRecord = dbContaxt.address.where(...);
fubar.addressId = existingRecord.id;
dbContext.table.Add(fubar);
}
dbContext.SaveChanges();
First issue, my changes are not being saved and I am not sure why.
Second issue, is there a more efficient way to do this? The collection can have thousands of records in it.
Would something like Parallel.ForEach() be appropriate here?
Thanks, Sammer