FSharp.Linq.ComposableQuery icon indicating copy to clipboard operation
FSharp.Linq.ComposableQuery copied to clipboard

An example where query works but dbquery doesn't using FCQ-Brands sample.

Open philderbeast opened this issue 11 years ago • 1 comments
trafficstars

I was using query and dbquery as the standard query expression and the replacement from ComposableQuery respectively and comparing the generated SQL. I found an example where query works but dbquery doesn't. The exception is as follows.

System.InvalidOperationException: System.Linq.IQueryable`1[System.Object] is not a GenericTypeDefinition. MakeGenericType may only be called on a type for which Type.IsGenericTypeDefinition is true.

I've added the setup as a db project. The database is named FCQ-Brands. To reproduce follow the readme at FSharp.Linq.ComposableQuery\tests\FCQ-Brands\readme.md and then open the script at FSharp.Linq.ComposableQuery\tests\FCQ-Brands\FCQ-Brands.fsx. There are comments in there with the results from query and the failure from dbquery.

The query is ...

let ofBrandUserAuth = <@ fun (b : string) ->
    if b = null then query {for a in db.UserAuth do select a} else
        query {
            for a in db.UserAuth do
            join un in db.UserName on
                (a.Id = un.AuthId)
            join bu in db.Brand_User on
                (un.Id = bu.User)
            where (bu.BrandBrand.Name = b)
            select a
        } @>

<@ fun b -> query {
    for a in (%ofBrandUserAuth) b do
    select a
} @>
|> fun q -> query {yield! (%q) brand}

philderbeast avatar Nov 02 '14 04:11 philderbeast

Interesting! I will take a look when I get a chance (might not be for a few days).

jamescheney avatar Nov 03 '14 18:11 jamescheney