I'm trying to query data using F # SqlDataProvider, but I got a weird error when I wanted to use the groupBy function
my initialization 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 request:
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. @ 1735-1.Microsoft-FSharp-Linq-ForwardDeclarations-IQueryMethods-Executea, b. $ FSI_0003.main @ () in C: \ Development \ CountriesParser \ Script1.fsx: line 36
Line 36 is the exact line of the By group.
As I read on these pages, it should work http://fsprojects.imtqy.com/FSharp.Linq.ComposableQuery/QueryExamples.html https://msdn.microsoft.com/en-us/library/hh225374.aspx
source share