How to delete an object by using PK in nhibernate?

后端 未结 5 1223

How do I delete an object without fetching it from the db first?

In another ORM, I can do this:

session.Delete(1); // 1 = PK
5条回答
  •  借酒劲吻你
    2021-02-02 17:08

    Check out the ExecuteUpdate method on the IQuery object.

    IQuery q = session.CreateQuery ("delete from User where Id = 1");
    q.ExecuteUpdate();
    

    Should delete the object without retrieving it afaik.

提交回复
热议问题