Remove method using linq
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)
精彩评论