In EF6, I want to update/delete bulk data in one query. My code is
using (var context = _dataContextFactory.GetContext())
{
var result1 = from b in context.MyTables
where new List<int> {592, 593, 594}.Contains(b.Id)
select b;
foreach (var item in result1 )
{
item.StatusId = 3;
}
context.SaveChanges();
}
But in Sql Profiler, there are three scripts
exec sp_executesql N'UPDATE [dbo].[MyTable] SET [StatusId] = @0 WHERE ([Id] = @1) ',N'@0 int,@1 int',@0=1,@1=592
exec sp_executesql N'UPDATE [dbo].[MyTable] SET [StatusId] = @0 WHERE ([Id] = @1) ',N'@0 int,@1 int',@0=1,@1=593
exec sp_executesql N'UPDATE [dbo].[MyTable] SET [StatusId] = @0 WHERE ([Id] = @1) ',N'@0 int,@1 int',@0=1,@1=594
is it possible to get script with Where In clause in one query?