DBFunctionCall in Predicate Expression

Posts   
 
    
prabhu
User
Posts: 77
Joined: 20-Dec-2006
# Posted on: 12-Dec-2007 04:22:40   

Hi,

I am using DBFunctionCall in predicate expression. The code is gn below

EntityField myField = ActivityHeaderFields.DatePerformed ;

myField.ExpressionToApply = new DbFunctionCall( "YEAR", new object[] { ActivityHeaderFields.DatePerformed } );

int[] values = new int[2] {2007, 2006}; predicateExpression.Add(new FieldCompareRangePredicate( myField, null, values));

When i try to pass integer values i.e 2006 and 2007 , type cast error is throwing.

This is the error i am getting " An exception was caught during the execution of a retrieval query: Failed to convert parameter value from a Int32 to a DateTime.. Check InnerException, QueryExecuted and Parameters of this exception to examine the cause of this exception."

Runtime generate the FieldCompareRangePredicate variables as DateTime but from the code i am passing integer values. Please let me know how to overcome this situation.

Regards

Prabhu

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 12-Dec-2007 04:49:54   

The comparison takes the type of the original field. A workaround could be use an integer field as original field. This wont affect the result as you are applying an expression:

EntityField myField = ActivityHeaderFields.SomeIntegerField;
David Elizondo | LLBLGen Support Team
prabhu
User
Posts: 77
Joined: 20-Dec-2006
# Posted on: 12-Dec-2007 05:48:47   

No i am checking against the dateperformed field to get list of Call details from ActivityHeader table. I am not able to understand what your telling.

Can you please clear me the same.

prabhu
User
Posts: 77
Joined: 20-Dec-2006
# Posted on: 12-Dec-2007 06:19:02   

Hi,

Thanks for the reply...I am able to retrieve the data .

Regards

Prabhu