This is a migrated thread and some comments may be shown as answers.

where error

1 Answer 36 Views
LINQ (LINQ specific questions)
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Zbigniew Kozłowski
Top achievements
Rank 1
Zbigniew Kozłowski asked on 26 Apr 2010, 09:40 AM
Hi,
ive got problem with a query:

var query = from contact in scope.Extent<Contact>() 
            where contact.Status.Equals(Common.Enums.Status.Active.ToString()) 
            select new 
            { 
                 contact.Id, 
                 contact.Description, 
                 contact.Phone1, 
                 contact.Fax, 
                 contact.Email1 
             }; 

after this i got exception:
Exception Message "Unknown column 'Active' in 'where clause'"

is it mine fault or something is wront with orm?


1 Answer, 1 is accepted

Sort by
0
Thomas
Telerik team
answered on 26 Apr 2010, 12:47 PM
Hi Zbigniew,

you should be able to execute that LINQ statement by using a temp variable:

 var st = Common.Enums.Status.Active.ToString();

var query = from contact in scope.Extent<Contact>() 
            where contact.Status.Equals(st) 
            select new 
            { 
                 contact.Id, 
                 contact.Description, 
                 contact.Phone1, 
                 contact.Fax, 
                 contact.Email1 
             }; 


In general, constant calculations should be moved outside the LINQ expression.

Kind regards,
Thomas
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Tags
LINQ (LINQ specific questions)
Asked by
Zbigniew Kozłowski
Top achievements
Rank 1
Answers by
Thomas
Telerik team
Share this question
or