1

我有以下表格:

客户 => 客户帐户 => 帐户

我也有一个 nHibernate 映射到上面每个表的 POCO。

我在实现的对象中有以下 lambda 表达式IIdentifier<T>

public Expression<Func<ICustomer, bool>> Filter
{
    get { return customer => customer.CustomerNumber == _customerNumber; }
}

现在我要做的是通过 a 加入 Customer => CustomerAccount => Account 表QueryOver<Account>

如何添加上述Filter客户类型的 lamdba 以按客户编号过滤?

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);

谢谢,

凯尔

4

1 回答 1

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));
于 2013-07-19T18:26:55.170 回答