Quantcast
Channel: Recent Threads — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 204402

Which function to tally total from rows in a table?

$
0
0

I am assuming that it's going to be a job for linq, but I cannot figure out how to make it work?

My biggest problem is that I am working on a field within the table.
I assume the code should look like this (minus my hideous oversimplification of the aggregate function)

public void GetSomeTotals()
{
    obervablecollection<dbtable> tabledata = await tablerepo.getitems();

    int totalItems = tabledata.Aggregate(func: (result, item) => result += item);
}

pseudo code

public void GetSomeTotals()
{
    obervablecollection<dbtable> tabledata = await tablerepo.getitems();
    int totalitems; 
    tabledata. ??? ( x => totalItems += x.Quantity);
}

I cannot get the second example to work, because the int object is outside of the scope.


Viewing all articles
Browse latest Browse all 204402

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>