I'm using the Dynamic Linq Library (this one) in my .NET MVC application to query a SQL Server database. It's all working fine so far.
However, the Dynamic Linq Library gives an "Expression expected" error whenever I use square brackets to designate troublesome column names containing spaces or hyphens. Here are some examples:
var query = context.FetchIceCream().AsQueryable().Where("Chocolate = 1"); // This is fine
var query = context.FetchIceCream().AsQueryable().Where("[Rum and Raisin] = 1"); // This results in an "Expression expected" error
I'm not able to rename any column names, so that's not an option - I need to be able to sort this out in code. I've searched high and low for a solution to this but to no avail... please help to save my sanity!
So I think this is the answer then:
The name you use in the Where clause must be a property of the object which you have in the Queryable collection.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With