Closed hunguyen75 closed 9 years ago
@hunguyen75
From 1.0.0 EFUtilities can do this. See the documentation at:
https://github.com/MikaelEliasson/EntityFramework.Utilities#batch-update-entities
Example:
var commentsFromDb = db.Comments.AsNoTracking().ToList();
var rand = new Random();
foreach (var item in commentsFromDb)
{
item.Reads = rand.Next(0, 9999999);
}
EFBatchOperation.For(db, db.Comments).UpdateAll(commentsFromDb, x => x.ColumnsToUpdate(c => c.Reads));
EFUtilities can't do this out of the box and there is no real support in SQL-Server that I know of. What you can do is to use the batch insert against a temporary table and then run a sql script to update the real table from that one.