There is my expected result for EF Core translating
UPDATE Table1
SET field1 = t2.field1,
field2 = t2.field2
FROM Table2 as t2
WHERE t1.Id1 != t2.Id2 AND
t1.Id2 = t2.Id2 AND
t2.SomeField > 0
But in SQL profiler I can see 1 query for every record that I am trying to update.
Here is my code.
var uploads = uow.Repository<Table2>().List(spec);
var errors = uow.Repository<Table1>().Get();
foreach (var upload in uploads)
{
var toUpdate = errors.Where(x =>
x.Id1 != upload.Id2 &&
x.Id2 == upload.Id2);
foreach (var error in toUpdate)
{
error.IsResolved = true;
}
}
uow.SaveChanges();
What you want is referred to as "bulk update", which isn't the default behavior for Entity Framework, but there are several NuGet packages out there that handle it properly.
You could have a look at EFCore.BulkExtensions for example.