sapiens / SqlFu

Fast and versatile .net core data mapper/micro-orm
Other
229 stars 50 forks source link

HandleParameter doesn't account for linq converts in expressions #78

Closed bgilner closed 8 years ago

bgilner commented 8 years ago

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)

sapiens commented 8 years ago

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.