I would like to update the testfield value on all records of the testEntity to "updated"
Which do you think is the best way?
Which do you think is the best way?
Case1:
var testEntities = context.CreateQuery<new_testentity>().Select(r => new { r.Id, r.testfield }); foreach (var record in testEntities) { var testEntity = context.GetAttachedEntities().First(); testEntity.testfield = "updated"; context.UpdateObject(testEntity); context.SaveChanges(); }
Case2:
var testEntities = context.CreateQuery<new_testentity>(); foreach (var record in testEntities) { context.Detach(record); var testEntity = new testEntity(); testEntity.testfield = "updated"; testEntity.Id = record.Id; context.Attach(testEntity); context.UpdateObject(testEntity); context.SaveChanges(); }
Case3:
var testEntities = context.CreateQuery<new_testentity>().ToList(); context.Detach(testEntities); foreach (var record in testEntities) { var testEntity = new testEntity(); testEntity.testfield = "updated"; testEntity.Id = record.Id; context.Attach(testEntity); context.UpdateObject(testEntity); context.SaveChanges(); }
Taichi,Sato