
Hi,
Firstly, excellent product!
I'm trying to group an array of json objects by 2 fields then sum another but am not having much luck with the syntax.
The data looks something like:
var TableArray = [ {BtmBucket:5, SizeBucket:1, Weight:5.2}, {BtmBucket:5, SizeBucket:1, Weight:3.9}, {.....} ]
The code I've got so far looks like:
var AggBucketData = Enumerable.From( TableArray ) .GroupBy( "{Btm:$.BtmBucket, Size:$.SizeBucket}", "$.Weight", "key,gp=>{btm:key.Btm, size:key.Size, Weight:gp.Sum()}" )
.ToArray();
Any help would be much appreciated. Thanks!
Nick



all JavaScript's object is not equal.
var _ = { A: 3 } == { A: 3 }; // false
so the add compareSelector for GroupBy.
var AggBucketData = Enumerable.From(TableArray)
.GroupBy("{Btm:$.BtmBucket, Size:$.SizeBucket}", "$.Weight", "key,gp=>{btm:key.Btm, size:key.Size, Weight:gp.Sum()}",
function (x) { return x.Btm + ':' + x.Size } // Add compareSelector
)
.ToArray();

