我有以下表格:
客户=> CustomerAccount =>帐户
我也有一个nHibernate映射POCO到上面的每个表。
我在实现IIdentifier<T>
public Expression<Func<ICustomer, bool>> Filter
{
get { return customer => customer.CustomerNumber == _customerNumber; }
}
现在我要做的就是加入Customer =&gt; CustomerAccount =&gt;帐户表格通过QueryOver<Account>
如何添加上述Filter
lamdba(类型为Customer),以按客户编号过滤?
ICustomer customer = null;
ICustomerAccount customerAccount = null;
IAccount account = null;
var query = QueryOver(() => account)
.JoinAlias(() => account.CustomerAccounts, () => customerAccount, JoinType.InnerJoin)
.JoinAlias(() => customerAccount.Customer, () => customer, JoinType.InnerJoin)
.Where(() => customerAccount.EndDate == null)
.And(() => account.IsPreferredAccount == true)
.And(() => ?? Want to add the above Filter() lambda some how here);
谢谢,
凯尔
答案 0 :(得分:2)
你可以尝试:
var query = QueryOver(() => account)
.JoinAlias(() => account.CustomerAccounts, () => customerAccount, JoinType.InnerJoin)
.JoinAlias(() => customerAccount.Customer, () => customer, JoinType.InnerJoin)
.Where(() => customerAccount.EndDate == null)
.And(() => account.IsPreferredAccount == true)
.And(Restrictions.Where<ICustomer>(Filter));