Just trying out F# 3.0 and hit a bit of a wall when it comes to grouping by multiple columns. The obvious thing to try was
query {
for d in context.table do
groupBy (d.col1,d.col2) into g
select (g.Key)
}
But I get a "Only parameterless constructors and initializers are supported in LINQ to Entities." exception.
I can't seem to find an example on msdn
http://msdn.microsoft.com/en-us/library/hh225374(v=vs.110).aspx
http://msdn.microsoft.com/en-us/library/hh361035(v=vs.110).aspx
And I realize my question is similar to " Entity Framework and Anonymous Types in F#" but it seems to be powerpack/F#2.x focused and I'm hoping F# 3.0 has an elegant answer... Any ideas?
UPDATE:
I came across the CLIMutable attribute from reading Brian's post at:
http://blogs.msdn.com/b/fsharpteam/archive/2012/07/19/more-about-fsharp-3.0-language-features.aspx
I was pretty optimistic so I tried
[<CLIMutable>]
type MyRecord = { Column1 : int; Column2 : int }
query {
for d in context.table do
groupBy {Column1 = col1; Column2 = col2} into g
select (g.Key)
}
Unfortunately I get the exact same exception.
question from:https://stackoverflow.com/questions/8650463/groupby-multiple-columns-in-a-f-3-0-query