linq to sql batch delete

后端 未结 4 1176
一生所求
一生所求 2021-01-13 01:06

I have the following DB: Posts which have an Id, Tags also with Id, and TagsToPosts table which have T

4条回答
  •  感情败类
    2021-01-13 01:40

    You can't do this with LINQ-to-SQL.

    LINQ-to-SQL is not good for batch operations - it can't do batch inserts, it can't do batch updates, and it can't do batch deletes. Every object in your collection is treated individually. You can do all the operations in one transaction, but there will always be a query for each record.

    MSDN

    A better option is to write a stored procedure that will do what you want.

提交回复
热议问题