Using an expression in the following format - MyDbSet.Select("new (int?(Id))") will throw an error if the Id property is of type int. This seems to be a bug in the original System.Linq.Dynamic project too.
One work around I have found is you can cast it to int64 first and then a nullable int like so MyDbSet.Select("new (int?(int64(Id)))")
The error only gets thrown once you try to evaluate the expression e.g. calling Count() on the first example
Using an expression in the following format -
MyDbSet.Select("new (int?(Id))")will throw an error if the Id property is of type int. This seems to be a bug in the original System.Linq.Dynamic project too.One work around I have found is you can cast it to int64 first and then a nullable int like so
MyDbSet.Select("new (int?(int64(Id)))")The error only gets thrown once you try to evaluate the expression e.g. calling
Count()on the first example