Post

2 followers Follow
0
Avatar

Query With AND

I need the syntax for a Query with 'AND' for c#. See below:

 

EntityQuery eq = new EntityQuery

{

TypeName = "task",

Fields = new string[] { "name", "Project.Name", "C_TaskGroup", "PercentCompleted", "DueDate", "C_TaskParent" },

Where = new Compare

{LeftExpression = new FieldExpression { FieldName = "C_TaskGroup" },

Operator = Operator.Equal,

RightExpression = new ConstantExpression { Value = new EntityId { TypeName = "C_GenericTaskTaskGroup", Value = "Storyboards" }}

AND

...second simple query such as State = 'active'

 

}

}

Bill Caughron Answered

Please sign in to leave a comment.

3 comments

1
Avatar

Hi Bill.

Please try something like this:

Where = new And

{

Conditions = new Condition[]

{

new Compare {LeftExpression = new FieldExpression {FieldName = "Name"}, Operator = Operator.BeginsWith, RightExpression = new ConstantExpression {Value="a"}},

new Compare {LeftExpression = new FieldExpression {FieldName = "StartDate"}, Operator = Operator.GreaterThan, RightExpression = new ConstantExpression {Value=new DateTime (2014,1,1)}}

}

}

Hope this helps,

Ophir

Ophir Kenig 1 vote
Comment actions Permalink