SELECT customer0_.CUSTOMER_ID AS x0_0_
FROM T_CUSTOMER customer0_
WHERE (customer0_.CUSTOMER_ID = 123456)
FROM T_CUSTOMER customer0_
WHERE (customer0_.CUSTOMER_ID = 123456)
Will be generated with next NHibernate Query:
public bool 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;
}
{
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.






0 comments:
Post a Comment