sapiens/SqlFu

HandleParameter doesn't account for linq converts in expressions

Closed this issue · 1 comments

ExpressionWriter.HandleParameter doesn't work for an expression such as:

x => ((IFoo)x).Foo ...

This is because the LINQ expresion generates:

{x => (Convert(x).Foo) ...

This fails the condition:

if (node.Expression.NodeType == ExpressionType.Parameter)

since the NodeType is Convert. It therefore generates invalid sql (missing the node.Member.Name)

SqlFu (present or future), doesn't do Linq. All it has are strongly typed sql builders which use expressions. The way you're trying to use it is 'ilegal' because it wasn't meant to be used like that. In SqlFu you're writing Sql either as a string or using a typed builder. But in both cases you should be thinking Sql. Unlike an ORM, in SqlFu Sql abstraction is merely a side effect, not an objective.