Skip to content

Instantly share code, notes, and snippets.

@jmarmolejos
Created December 19, 2012 15:57
Show Gist options
  • Save jmarmolejos/4337770 to your computer and use it in GitHub Desktop.
Save jmarmolejos/4337770 to your computer and use it in GitHub Desktop.
// My first attempt
var appointments = _context.T_APPOINTMENT.Where(c => ids.Contains(c.CUSTOMER_ID));
foreach (var appointment in appointments)
{
appointment.CUSTOMER_ID = newCustomer.CUSTOMER_ID;
_context.T_APPOINTMENT.ApplyCurrentValues(appointment);
}
_context.SaveChanges();
// My second, optimized for performance, attempt
var query = string.Format("Update T_APPOINTMENT SET CUSTOMER_ID = {0} where CUSTOMER_ID in ({1})",
newCustomer.CUSTOMER_ID,
string.Join(",", ids));
_context.ExecuteStoreCommand(query);
_context.SaveChanges();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment