Howto? WHERE (a OR b) AND c

Posts   
 
    
benles
User
Posts: 62
Joined: 02-May-2005
# Posted on: 22-Jun-2005 19:06:44   

I'm having trouble understanding how to properly group these expressions:

IPredicateExpression filter = new PredicateExpression();

filter.Add(PredicateFactory.Like(ProjectFieldIndex.Subdomain, ProjectName)); filter.AddWithOr(PredicateFactory.Like(ProjectFieldIndex.Domain, ProjectName));

filter.AddWithAnd(PredicateFactory.CompareValue(ProjectFieldIndex.Archived, ComparisonOperator.Equal, 0)); p.GetMulti(filter);

JimFoye avatar
JimFoye
User
Posts: 656
Joined: 22-Jun-2004
# Posted on: 22-Jun-2005 20:17:37   

benles wrote:

I'm having trouble understanding how to properly group these expressions:

IPredicateExpression filter = new PredicateExpression();

filter.Add(PredicateFactory.Like(ProjectFieldIndex.Subdomain, ProjectName)); filter.AddWithOr(PredicateFactory.Like(ProjectFieldIndex.Domain, ProjectName));

filter.AddWithAnd(PredicateFactory.CompareValue(ProjectFieldIndex.Archived, ComparisonOperator.Equal, 0)); p.GetMulti(filter);

I believe this is the relevant example from the manual:

// [C#]
RelationPredicateBucket B = new RelationPredicateBucket();
IPredicateExpression A = new PredicateExpression();
A.Add(PredicateFactory.CompareValue(Table1FieldIndex.Foo, ComparisonOperator.Equal, "One"));
A.AddWithAnd(PredicateFactory.CompareValue(Table1FieldIndex.Bar, ComparisonOperator.Equal, "Two"));
B.PredicateExpression.Add(A);
B.PredicateExpression.AddWithOr(PredicateFactory.CompareValue(Table2FieldIndex.Bar2, ComparisonOperator.Equal, "Three"));

Look at "Generated code - Filtering and sorting, Adapter"