Next SQL, which verifies if customer row exists in database:
SELECT customer0_.CUSTOMER_ID AS x0_0_ FROM T_CUSTOMER customer0_ WHERE(customer0_.CUSTOMER_ID =123456)
Will be generated with next NHibernate Query:
publicbool CustomerExistsInDatabase(Int32 customerId) {
var result = Session.CreateQuery(string.Format(“select c.CustomerID from Customer c where c.CustomerID = {0}”, customerId)).UniqueResult<Int32?>();
return result.HasValue; }
Please note, that you could use not only primary key, but any other property in your where condition.
codemore code
~~~~