I'm looking at the Where_datetime_now test and wondering where type of myDatetime later as a SqlParameterExpression is coming from? I'm getting wrong type mapping of string there. But I can't figure out where is this inferred (and hence change/fix it).
You're asking about the store type for the myDateTime parameter being sent to the database, right (in other words the type mapping)?
If so, unless I'm mistaken, the type mapping is going to depend on how you implemented the translation for DateTime.Now (on the left-hand side) - this is how inference works since 3.0. Parameters by their nature don't come with a type mapping (since all we have is a CLR type), so their type mapping is inferred from the the context. In this case, DateTime.Now will likely translate to a function expression, which should have a type mapping (for whatever is the DateTime equivalent in your database). Since the left-hand side has a type mapping and the right-hand side doesn't, the left-hand side mapping gets applied to the right-hand side.
tl;dr check your translation of DateTime.Now and what type mapping its resulting expression has.
My LHS is SqlFragmentExpression, which does not have a type mapping. 馃槷
Looks like niladic SqlFunctionExpression solves it. Thanks for a great pointer.
Yeah, SqlFragmentExpression is really meant only for cases where there is no other alternative. A niladic SqlFunctionExpression is much better.
Little correction: SqlFragmentExpression is meant to print a particular token in SQL tree. (as Brice refers to it). SqlFragmentExpression does not have type mapping because it is not a value which is supposed to be read from DataReader.
Most helpful comment
Looks like niladic
SqlFunctionExpressionsolves it. Thanks for a great pointer.