This project is read-only.

oData creates incompatible SQL

Topics: ASP.NET Web API
Apr 9, 2014 at 2:42 PM
Edited Apr 9, 2014 at 2:42 PM
I've found a case where oData is generating expression trees differently to it's counter part straight to dbcontext.

This isn't a bad thing normally, but it is generating SQL incompatible with SQL Server in compatibility mode 80. I realise a SQL server upgrade would sort this, but seeing as hitting the dbcontext directly works fine, it makes me think that somewhere in oData it's going astray.

I've posted a lengthy investigation on stackoverflow
Apr 9, 2014 at 3:34 PM
After lots of digging I've uncovered the cause and the (nicely simple) fix. It would be really cool that if compatibility mode 80 was detected that it would set EnableConstantParameterization to false. But I understand this would mean being quite chatty with Entity Framework.

Perhaps just a note for the edge case gotchas.

The solution:
Marked as answer by alexkey on 4/9/2014 at 7:34 AM