我有以下表格:
Customer => CustomerAccount =>帐户
我也有一个映射到上面每个表的nHibernate POCO。
我在一个实现IIdentifier<T>的对象中有以下lambda表达式
public Expression<Func<ICustomer, bool>> Filter
{
get { return customer => customer.CustomerNumber == _customerNumber; }
}现在,我要尝试通过QueryOver<Account>连接Customer => CustomerAccount =>帐户表
如何添加上述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);谢谢,
凯尔
发布于 2013-07-20 02:26:55
您可以尝试:
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));https://stackoverflow.com/questions/17728956
复制相似问题