Ehsan
Ehsan

Reputation: 3491

How delete object by sending query to Session.Delete(...) in Nhibernate 3.3.3.4001

I have the following block of code which should ultimately delete a record.

long id = 81;
SessionInstance.Delete("from Core.Domain.Model.Person as obj where obj.Id =:id", id, NHibernateUtil.Int64);

But after upgrade Nhibernate version to 3.3.3.4001, this code has a exception by this message :

The given key was not present in the dictionary.

Why?

Upvotes: 3

Views: 7473

Answers (1)

Ricardo Peres
Ricardo Peres

Reputation: 14535

If you want to use positional parameters (which you need to), the syntax is a bit different:

session.Delete("from Product p where p.ProductId = ?", id, NHibernateUtil.Int32);

Upvotes: 3

Related Questions