开发者

Remove method using linq

开发者 https://www.devze.com 2023-01-27 08:23 出处:网络
How do I implement the following method (preferably without fetching the items from开发者_Python百科 the database first):

How do I implement the following method (preferably without fetching the items from开发者_Python百科 the database first):

public void Remove(Expression<Func<TEntity, bool>> query)
{
  _session.XXXXXXX
}

It's for my repository class.


I'm afraid that's not currently possible, as Linq in NH is only supported for data-retrieving queries, not updates.

An alternative is using HQL updates: http://nhibernate.info/doc/nh/en/index.html#batch-direct

The end result is the same: HQL queries are type-safe and compiled (by NHibernate)

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号