Custom Predicate not based on table fields

Posts   
 
    
pg
User
Posts: 13
Joined: 19-Oct-2005
# Posted on: 04-Jan-2007 14:35:57   

Is it possible to add a pedicate to a PredicateExpression that is not based on existing fields?

For example, I want to add the following clause to my query:

select ... where (getdate() <= <dateCondition>)

Is it possible to create this condition based on getdate() (instead of an existing field) in llblGen ver 2.0?

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 04-Jan-2007 16:24:02   

Yeah sure. Would be something like:


DataAccessAdapter adapter = new DataAccessAdapter();
RelationPredicateBucket bucket = new RelationPredicateBucket();

IExpression GetDateExp = new DbFunctionCall("GETDATE", null);

// just create any field, won't matter, our expression will dominate.
EntityField2 field = OrdersFields.OrderDate.SetExpression(GetDateExp);

bucket.PredicateExpression.Add(new FieldCompareValuePredicate(field, null, ComparisonOperator.LessEqual, dateCondition));

adapter.FetchEntityCollection(Orders, bucket);

pg
User
Posts: 13
Joined: 19-Oct-2005
# Posted on: 05-Jan-2007 13:41:38   

It worked. thanks...

Walaa wrote:

Yeah sure. Would be something like:


DataAccessAdapter adapter = new DataAccessAdapter();
RelationPredicateBucket bucket = new RelationPredicateBucket();

IExpression GetDateExp = new DbFunctionCall("GETDATE", null);

// just create any field, won't matter, our expression will dominate.
EntityField2 field = OrdersFields.OrderDate.SetExpression(GetDateExp);

bucket.PredicateExpression.Add(new FieldCompareValuePredicate(field, null, ComparisonOperator.LessEqual, dateCondition));

adapter.FetchEntityCollection(Orders, bucket);