I have a F # sql query that should sum two columns in each group.
let financials = query{
for data in dbData do
groupValBy (data.earning, data.losses) data.store into group
select (group.Key, group.Sum(fun (group) -> fst group), group.Sum(fun (group) -> snd group))
}
I could not find examples of how to do this, however, this code compiles fine, and for every sign it should work. However, when I execute, I always get an exception with this message: "Failed to format node" New "for execution as SQL." If I delete data.losses everything works fine, but adding a second value causes an error. Is there any other way to do this? Suggestions will be appreciated.
Note. This question is similar, but handles the opposite situation in which multiple columns are grouped : group multiple columns in a F # 3.0 query
UPDATE:
I also tried the following:
(NewAnonymousObjectHelper(T(data.earning, data.losses)))
where T:
type T(earning : decimal, losses : decimal) =
member val Earning=earning with get,set
member val Losses=losses with get,set
Sum, T. MutableTuple F # PowerPack, MutableTuple ( /dll ). , :
let t = MutableTuple<_,_>(item1=data.earning,item2=data.losses)
groupValBy t data.store into group
, - , .
:
, , - . , group.Sum() . (: , , sql.)