Closed katatunix closed 2 years ago
There are unit tests exercising this, so it should work.
Maybe the problem is because you are not following the query expression with a call to SelectAsync
.
For example:
select {
table "Players"
innerJoin "Games" "Id" "GameId"
where (eq "Players.Id" playerId.Value)
}
|> conn.SelectAsync<Player, Game>
Also, have you tried using the Linq API?
It would be something like this:
open Dapper.FSharp.LinqBuilders
let playersTable = table'<Player> "Players"
let gamesTable = table'<Game> "Games"
select {
for p in playersTable do
join g in gamesTable on (p.GameId = g.Id)
where (p.Id = playerId.Value)
}
|> conn.SelectAsync<Player, Game>
Maybe the problem is because you are not following the query expression with a call to
SelectAsync
.
Of course I have the SelectAsync
there. The code was totally OK on v2.1.0.
Also, have you tried using the Linq API?
Let me try now, but only for investigation purpose, personally I don't like Linq :D
Sure. I only asked in the spirit of troubleshooting. 😉
Maybe one guess. Do you use version of F# >= 5 or having preview flag in fsproj?
I recently changed API with using custom operation overloads and marking old methods as Obsolete... So maybe that's the issue.
The Linq API works, except that there is a little warning on join g in gamesTable on (p.GameId = g.Id)
: The value g is unused
. But if I change the first g
to _
, it becomes an error.
I'm using JetBrains Rider.
By the way, I changed my mind, Linq API is better, since it's more type-safe, especially in where
clause.
Any yes, I'm using F# 5, but not having preview flag.
I have the exact same issue, also on 5. Do I really have to downgrade to dotnet core 3.1 to be able to use version > 2.1.0 of this library?
Do I really have to downgrade to dotnet core 3.1 to be able to use version > 2.1.0 of this library?
Nope, please use the preview
flag in fsproj. We will see where it will go with v3, but my goal is to aim directly for .NET6
The code compiled OK on v2.1.0:
However with v2.2.0 and v.2.3.0, the compiler reported an error as below:
I tried with
innerJoin "Games" [ ("Id", "GameId") ]
but the error is still there.