typed view getscalar

Posts   
 
    
jspanocsi
User
Posts: 145
Joined: 04-Mar-2005
# Posted on: 04-May-2005 15:21:14   

Is there any way to do a

select sum(field1) from someview where ...

with a typed view? I need a sum of dollar amounts from a view and can't seem to get it working.

Thanks!

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 04-May-2005 15:23:49   

What code did you try? perhaps it's a small thing.

Frans Bouma | Lead developer LLBLGen Pro
jspanocsi
User
Posts: 145
Joined: 04-Mar-2005
# Posted on: 04-May-2005 17:10:47   

well, I'm stuck on what to start with also. It doesn't have a get scalar like a collection does so I thought of using some group by stuff, but I really don't need that either. Just a typedview with a filter on it and then a select sum(somecol) from the remaining rows.

Thanks

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 04-May-2005 17:53:53   

Typed Views don't have a getscalar, though you can use the TypedListDAO to get a scalar value.

ResultsetFields fields = new ResultsetFields(1); fields.DefineField(MyTypedViewFieldIndex.ColumnName, 0, "Summation"); fields[0].AggregateFunctionToApply=AggregateFunction.Sum; // formulate your predicates here TypedListDAO dao = new TypedListDAO(); object sumValue = dao.GetScalar(fields, null, null, null, null, true);

Of course, if you want to pass in a filter, you should specify it in the GetScalar call.

Frans Bouma | Lead developer LLBLGen Pro
jspanocsi
User
Posts: 145
Joined: 04-Mar-2005
# Posted on: 04-May-2005 20:04:54   

Thanks. That worked great.