Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Query translator produces invalid results for queries that use groupby #39

Closed
KevinRansom opened this issue Jan 18, 2015 · 0 comments
Closed
Labels
Area-Queries Query expressions and library implementation Bug Impact-Low (Internal MS Team use only) Describes an issue with limited impact on existing code.
Milestone

Comments

@KevinRansom
Copy link
Member

Opened at CodePlex by: latkin

In F# queries with groupBy clauses, invalid query translation can occur.

Repro: Download bmovie-data.mdf from F# 3.0 Sample Pack, path OtherSamples\BMovieMadness\CSharpMvcApp\App_Data\bmovie-data.mdf

Run the following in script or console app

#r "FSharp.Data.TypeProviders"
#r "System.Data.Entity"

[<Literal>]
let connectionString = @"Data Source=(LocalDb)\v11.0;Initial Catalog=bmovie-data;Integrated Security=SSPI;AttachDBFilename=D:\en\fs3sample\OtherSamples\BMovieMadness\CSharpMvcApp\App_Data\bmovie-data.mdf"
type internal T = Microsoft.FSharp.Data.TypeProviders.SqlEntityConnection<ConnectionString = connectionString, ForceUpdate=false>

open System.Linq

let internal db = T.GetDataContext()
let userIds = [| System.Guid() |]

let topGenres = query {
    for u in db.Users do
    where (userIds.Contains u.UserId)
    for g in u.UserGenres do
    groupBy (g.GenreId) into gr
    let k = gr.Count()
    sortBy k
    select gr.Key
    }
topGenres |> Seq.take 1 |> Seq.toArray

Result: System.NotSupportedException: Only parameterless constructors and initializers are supported in LINQ to Entities.

@latkin latkin added the Bug label Jan 19, 2015
@dsyme dsyme added the pri-2 label May 12, 2015
@dsyme dsyme added this to the VS 2015 milestone May 12, 2015
@dsyme dsyme removed this from the VS 2015 milestone May 20, 2015
@KevinRansom KevinRansom removed the pri-2 label Dec 4, 2015
@dsyme dsyme added Impact-Low (Internal MS Team use only) Describes an issue with limited impact on existing code. Area-Library Issues for FSharp.Core not covered elsewhere labels Jan 8, 2016
@cartermp cartermp added this to the Unknown milestone Aug 25, 2018
@cartermp cartermp modified the milestones: Unknown / not bug, Backlog May 23, 2019
@dsyme dsyme added Area-Queries Query expressions and library implementation and removed Area-Library Issues for FSharp.Core not covered elsewhere labels Mar 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Queries Query expressions and library implementation Bug Impact-Low (Internal MS Team use only) Describes an issue with limited impact on existing code.
Projects
Archived in project
Development

No branches or pull requests

4 participants