Predicate containing DBFunctionCall

Posts   
 
    
Ups_Weera
User
Posts: 4
Joined: 31-Oct-2006
# Posted on: 31-Oct-2006 23:36:32   

Hi I am using LLBLGen Pro v.2, Adapter template. I am working on a proof of concept sample application and I want to achieve equavelant of the following MS SQL statement (using Adventure works database):


select * from sales.salesorderHeader
where month(orderDate) =9;

Here is what I have done, that doesn't work:


RelationPredicateBucket bucket = new RelationPredicateBucket();

IPredicateExpression filter3 = new PredicateExpression();

 filter3.Add( new DbFunctionCall("Month", new object[] { SalesOrderHeaderFields.OrderDate }) == int.Parse(txtParameter3.Text));
...



where txtParameter3 is a text box that will contain the month for which I want to retrieve orders.

I get an error on the last line of code above, that says == cannot be used for such comparison.

I know that in the manual there is an example, that does not quite apply to my situation, because I use an entity collection as follows:


 adapter.FetchEntityCollection(salesOrders, bucket);

Where adapter is my dataAccessAdapter and salesOrder is entitycollection<SalesOrderHeaderEntity>.

I appreciate your help.

Weera,

bclubb
User
Posts: 934
Joined: 12-Feb-2004
# Posted on: 01-Nov-2006 06:35:38   

try this instead


filter3.Add( SalesOrderHeaderFields.OrderDate.SetExpression(new DbFunctionCall("Month", new object[] { SalesOrderHeaderFields.OrderDate })) == int.Parse(txtParameter3.Text));
Ups_Weera
User
Posts: 4
Joined: 31-Oct-2006
# Posted on: 01-Nov-2006 16:21:37   

Thanks Alot!!! It works!smile