where error

2 posts, 0 answers
  1. Zbigniew Kozłowski
    Zbigniew Kozłowski avatar
    60 posts
    Member since:
    Apr 2010

    Posted 26 Apr 2010 Link to this post

    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?


  2. Thomas
    Admin
    Thomas avatar
    590 posts

    Posted 26 Apr 2010 Link to this post

    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.
  3. DevCraft banner
Back to Top