Entity Framework 6 Where in Bulk Update/Delete in one transaction

后端 未结 2 946
旧时难觅i
旧时难觅i 2021-01-18 12:35

In EF6, I want to update/delete bulk data in one query. My code is

 using (var context = _dataContextFactory.GetContext())
            {
                var         


        
2条回答
  •  旧时难觅i
    2021-01-18 13:06

    You can't update multiple rows in one single SQL call with EF.

    What you could do instead is to write a stored procedure that'll do the job efficiently for you. Or use a third party lib that provides extensions to EF to do it.

    Of course, it won't makes sense if the number of rows to update is really small.

提交回复
热议问题