0

Suppose I have following domain models:

 public class Fund : EntityBase
    {
        public virtual string Name { get; set; }
        public virtual IList<FundDetail> FundDetails { get; set; }
        public Fund()
        {
            FundDetails=new List<FundDetail>();

        }
    }
  public class FundDetail : EntityBase
    {
        public virtual string Symbol { get; set; }
        public virtual Fund Fund { get; set; }
    }

Now i would like to get all funds where fund name or fund details ymbol contains some string value:

 var funds = _fundRepository.QueryOver()
                    .Left.JoinAlias(c => c.FundDetails, () => fundDetail)
                    .Future().ToList();

How to use "or" clause in QueryOver? so I need to query all funds where :

string filterVal="someval";
c=>c.Name.Lower().Contains(filterVal) or fundDetail.Symbol.Lower().Contains9filterVal

Thanks.

Nic
  • 1,088
  • 3
  • 19
  • 43

1 Answers1

0

You could add a call to the Where method:

string filterVal = "someval";
var funds = _fundRepository.QueryOver<Fund>().
                .Where(c => c.Name.Lower().Contains(filterVal) ||
                           c.fundDetail.Symbol.Lower().Contains(filterVal))
                .Left.JoinAlias(c => c.FundDetails, () => fundDetail)
                .Future().ToList();

Check out this article to get an idea of all other options regarding QueryOver.

Jeroen
  • 1,246
  • 11
  • 23