I need to use the SQRT function as part of a where clause in a Linq EF query. I figured I could do this:
var qry = context.MyTable.Where("sqrt(it.field) > 1");
But it returns an error saying “‘sqrt’ cannot be resolved into a valid type constructor or function., near function, method or type constructor, line 6, column 5.”
I had always assumed that linq literally takes what’s in the where clause and translates that into a statement that is executed directly in SQL. That doesn’t seem to be the case…
Anyone know the work-around?
Thanks
I’m using Linq Entities and was able to do this:
When I check the generated SQL, I get
This seems reasonable. I was unable to use the .Where string format to reproduce the same code, but I’m probably missing something obvious.