Scalar querey with multiple predicates

Posts   
 
    
duds
User
Posts: 15
Joined: 26-Aug-2008
# Posted on: 26-Aug-2008 09:38:47   

Hi,

I'm trying to create the following sql:

Select sum(value) From Target_Kpi_Mth Where user_id = 'jgardner' And kpi_id = 19 And season = 2008

I have tried using adapter.GetScalar() like this:

**IPredicate filter = (AgentsTargetKpiMthFields.UserId == sfUserId);

tkgData.KpiTarget = Convert.ToDouble(adapter.GetScalar(AgentsTargetKpiMthFields.Value, null, AggregateFunction.Sum, filter)); **

and it works, but as far as I can see it only takes a single IPredicate so I don't know how to get the other two predicates into the query.

Is there a way to get multiple filters, or pass in a RelationPredicateBucket? Or should I be doing something completely different.

thanks,

james.

DvK
User
Posts: 318
Joined: 22-Mar-2006
# Posted on: 26-Aug-2008 09:48:30   

Just pass a PredicateExpression as filter !

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 26-Aug-2008 09:53:35   

Yeah, you could do something like:

IPredicateExpression filter = AgentsTargetKpiMthFields.UserId == sfUserId
     & AgentsTargetKpiMthFields.OtherField == otherValue
     | AgentsTargetKpiMthFields.OtherField2 == otherValue2;

or

IPredicateExpression filter = new PredicateExpression();

filter.Add(AgentsTargetKpiMthFields.UserId == sfUserId);
filter.Add(AgentsTargetKpiMthFields.OtherField == otherValue);
filter.AddWithOr(AgentsTargetKpiMthFields.OtherField2 == otherValue2);
David Elizondo | LLBLGen Support Team
duds
User
Posts: 15
Joined: 26-Aug-2008
# Posted on: 26-Aug-2008 09:58:21   

Thanks DvK & daelmo.