Wednesday, October 30, 2013

mysql .net Unknown column in 'where clause'

I was having the error :

"Unknown column 'Extent1.Name' in 'where clause'"

The code was:

var companies = (from cp in skydeskDB.Companies
    where cp.OrganizationId == parameters.OrganizationId                                    
    &&  cp.Name.Contains(parameters.Filter)                                                    
      select cp
).OrderBy(cp => cp.Name);


the solution was changing  select cp to select new { cp } :

var companies = (from cp in skydeskDB.Companies

    where cp.OrganizationId == parameters.OrganizationId                                    
    &&  cp.Name.Contains(parameters.Filter)                                                    
      select new { cp } // here
).OrderBy(cp => cp.Name);



No comments: