Typically the functions associated with the member variable needs to be mapped in the Sql builder(for Expressions); for example string's ToUpper() function is mapped internally to sql's UPPER() function. Since the Sql Builder does not know what is GetValueOrDefault (as this function is not mapped to any SQL function) , it is erroring out. I'm not sure what SQL statement can be used for this, if you have a valid case for it, please create a ticket in the Github.
Linq.Expression with a Nullable<'T> type
-
23-06-2022 - |
Question
I am trying to build a simple Count function in F# 3.0 with OrmLite which looks like this :
let x =
use conn = dbFactory.Open() //IDbConnection
conn.Count<Area>(fun (x:Area) -> x.parent_id.GetValueOrDefault(0) > 0)
where
type Area() =
//...
member val parent_id = Nullable<_>() with get, set
But I get the error :
System.InvalidOperationException: variable 'x' of type 'FSI_0029.Area' referenced from scope '', but it is not defined
The following works :
let x =
use conn = dbFactory.Open()
conn.Count<Area>(fun (x:Area) -> x.id > 0)
So I assume it has to do with the Nullable<_> type.
Has anyone encountered this issue ?
Many thanks in advance,
Solution
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow