I'm trying to query data with F# SqlDataProvider but I got strange error when I'd like to use groupBy function
my init code :
r# "packages/FSharp.Data.2.2.5/lib/net40/FSharp.Data.dll"
r# "packages/SQLProvider.1.0.0/lib/FSharp.Data.SQLProvider.dll"
r# "packages/FSharp.Data.TypeProviders.5.0.0.2/lib/net40/FSharp.Data.TypeProviders.dll"
open FSharp.Data
open FSharp.Data.Sql
open FSharp.Data.TypeProviders
open FSharp.Linq
open System.Text.RegularExpressions
open System
open System.Data
type dbSchema = SqlDataProvider<
ConnectionString = "my-connection-string",
DatabaseVendor = Common.DatabaseProviderTypes.MSSQLSERVER,
IndividualsAmount = 1000,
UseOptionTypes = true>
let db = dbSchema.GetDataContext()
my query :
query {
for county in db.Dbo.Countries do
groupBy county.CountryCode into g
select (g.Key, g.Count())
} |> Seq.iter (fun (key, count) -> printfn "%s %d" key count)
I got this error :
System.Exception: unrecognised method call at Microsoft.FSharp.Linq.RuntimeHelpers.LeafExpressionConverter.EvaluateQuotation(FSharpExpr e) at Microsoft.FSharp.Linq.QueryModule.EvalNonNestedInner(CanEliminate canElim, FSharpExpr queryProducingSequence) at Microsoft.FSharp.Linq.QueryModule.clo@1735-1.Microsoft-FSharp-Linq-ForwardDeclarations-IQueryMethods-Executea,b at .$FSI_0003.main@() in C:\Development\CountriesParser\Script1.fsx:line 36
The line 36 is exact line of groupBy.
As I read in these pages, it should work http://fsprojects.github.io/FSharp.Linq.ComposableQuery/QueryExamples.html https://msdn.microsoft.com/en-us/library/hh225374.aspx