JordanMarr / SqlHydra

SqlHydra is a suite of NuGet packages for working with databases in F# including code generation tools and query expressions.
MIT License
212 stars 20 forks source link

NoWarn 3391 #97

Open RicoSaupeBosch opened 1 week ago

RicoSaupeBosch commented 1 week ago

I am trying out the selectTask example exactly as in the documentation on a net8.0 console application. I am getting a warning which i cannot figure out. Am I missing something or do I really have to add nowarn?

these are my references

<PackageReference Include="Microsoft.Data.SqlClient" Version="5.2.1" />
<PackageReference Include="SqlHydra.Query" Version="2.5.1" />

the warning

This expression uses the implicit conversion 'static member ContextType.op_Implicit: createFn: (unit -> QueryContext) -> ContextType' to convert type 'unit -> QueryContext' to type 'ContextType'. See https://aka.ms/fsharp-implicit-convs. This warning may be disabled using '#nowarn "3391".

image

JordanMarr commented 1 week ago

selectAsync and selectTask allow you to implicitly pass in an openContext function or an existing "Shared" context. F# now allows implicit conversion but you have to opt in by disabling the warning

So, if you want the simpler, implicit context, you should add the #nowarn directive. Otherwise, you can explicitly wrap it in the ContextType discriminated union:

selectAsync HydraReader.Read (Create openContext) {
    for s in dbo.Systems do
    select s
}
RicoSaupeBosch commented 1 week ago

Thanks that was it. Could I have seen that in some documentation of yours? I may have overlooked it.

JordanMarr commented 1 week ago

No, that is not in the docs.