How to delete multiple db entities with Nhibernate?

前端 未结 3 1253
情书的邮戳
情书的邮戳 2021-02-05 13:47

What is the best practice for this problem? Is there any batching features built-in?

Sample code:

using (ITransaction transaction = _session.BeginTransa         


        
3条回答
  •  南方客
    南方客 (楼主)
    2021-02-05 14:49

    I had problems getting the answer to work and I found the following query worked 100%

            Session.CreateQuery("delete Customer c where c.id in (:deleteIds)")
                .SetParameterList("deleteIds", deleteIds)
                .ExecuteUpdate();
    

    Customer is the class name not the table name. id is lowercase and in HQL it is the Primary Key not a property name in the class (Property names are supported)

提交回复
热议问题