NHIbernate OR Criteria Query

前端 未结 3 1321
日久生厌
日久生厌 2020-12-31 13:47

I have the following mapped classes

Trade { ID, AccountFrom, AccountTo }
Account {ID, Company}
Company {ID}

Now I cannot figure out a way s

3条回答
  •  一向
    一向 (楼主)
    2020-12-31 14:26

    Try:

    return session.CreateCriteria()
        .CreateAlias("AccountFrom", "af")
        .CreateAlias("AccountTo", "at")
        .Add(Restrictions.Or(
            Restrictions.Eq("af.Company.CompanyId", companyId), 
            Restrictions.Eq("at.Company.CompanyId", companyId)))
        .List();
    

    I don't think you will need to alias Company.

提交回复
热议问题