nHibernate QueryOver‹T› Сложность

У меня есть следующие таблицы:

Клиент => CustomerAccount => Аккаунт

У меня также есть сопоставление POCO nHibernate с каждой из таблиц выше.

У меня есть следующее лямбда-выражение в объекте, который реализует IIdentifier<T>

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

Теперь я пытаюсь присоединиться к таблицам Customer => CustomerAccount => Account через QueryOver<Account>

Как добавить указанную выше Filter лямбду, имеющую тип 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);

Спасибо,

Кайл


person Kyle Novak    schedule 18.07.2013    source источник


Ответы (1)


Вы можете попробовать:

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));
person Andrew Whitaker    schedule 19.07.2013