I'm getting data out of my object context using .CreateQuery(sqlStatement, parameterValues). Please note that this the Entity SQL that I am using as a string constant being passed into the CreateQuery method, not a compiled LINQ query in my source code.
This works perfectly. However there are some duplicate records...
ctx.CreateQuery<DbDataRecord>(@"SELECT record.home_city, record.home_stabb
FROM Employees AS record
ORDER BY record.home_city SKIP 0 LIMIT 15",prms);
So I thought this would remove the duplicates:
ctx.CreateQuery<DbDataRecord>(@"SELECT DISTINCT record.home_city, record.home_stabb
FROM Employees AS record
ORDER BY record.home_city SKIP 0 LIMIT 15",prms);
Exact same statement, exact same object context. However, when I add in the DISTINCT Modifier, I get the exception below. I know all of the columns are correct because the first statement works perfectly. Jusjing by the exception, it appears to have a problem with the ORDER BY clause.
Is there something that I'm missing? This makes no sense to me.
System.Data.EntitySqlException was unhandled by user code
Message='record.home_city' could not be resolved in the current scope or context. Make sure that all referenced variables are in scope, that required schemas are loaded, and that namespaces are referenced correctly. Near member access expression, line 1, column 95.
Source=System.Data.Entity
Column=95
ErrorContext=member access expression, line 1, column 95