public IList<Customer> QueryAllCustomerHasOrdersByHSql() {
return Session.CreateQuery("from Customer c where exists( from Order a where a.Customer=c.Id)").List<Customer>();
}
public IList<Customer> QueryAllCustomerHasOrdersBySql() {
return Session.CreateSQLQuery("select c.* from Customer c where exists(select b.Customer from `Order` b where b.Customer=c.CustomerId)")
.AddEntity("c",typeof(Customer)).List<Customer>();
}
//public IList<Customer> QueryAllCustomerHasOrdersByCriteria() {
//return Session.CreateCriteria(typeof(Customer))
// .Add(Restrictions.In("Customer",))
//}
如何使用 CreateCriteria Restrictions 實現上面使用SQL的查詢功能
http://stackoverflow.com/questions/1752792/nhibernate-createcriteria-and-exists-clause