none
OrderBy not working

    Question

  • Hi,

    I am trying to sort my companies by CompanyName. However, I do not get intellisense when I do OrderBy(c => c.CompanyName).

    when I type c. (C and dot), it does not show CompanyName.

    Why this is happening? Why can't I all the properties from the collection?

    public IQueryable<tblCompany> GetTblCompanies()
    {
        return this.ObjectContext.tblCompanies.OrderBy(c => c.CompanyName);
    }

    Cheers

    C

     

    Monday, February 06, 2012 1:19 PM

Answers

  • Do you have an "include System.Linq;" line in your file?

    Also, I don't know your situation, but FYI, an OrderBy on the server won't help if you are using RIA Services and binding to a collection on the client.

    Monday, February 06, 2012 1:37 PM
  • Is intellisence correctly resolving the type of tblCompany and c if you hover over them?  Are other properties from tblCompany avialable in intellisense?

    If so, it seems there must be a problem with the CompanyName property itself.

    Otherwise it could be a missing "using" for the namespace that contains tblCompany.

    Monday, February 06, 2012 5:43 PM

All replies

  • Do you have an "include System.Linq;" line in your file?

    Also, I don't know your situation, but FYI, an OrderBy on the server won't help if you are using RIA Services and binding to a collection on the client.

    Monday, February 06, 2012 1:37 PM
  • Monday, February 06, 2012 2:00 PM
  • Hi,

    I do have system.linq on my page.

    Monday, February 06, 2012 3:27 PM
  • Is intellisence correctly resolving the type of tblCompany and c if you hover over them?  Are other properties from tblCompany avialable in intellisense?

    If so, it seems there must be a problem with the CompanyName property itself.

    Otherwise it could be a missing "using" for the namespace that contains tblCompany.

    Monday, February 06, 2012 5:43 PM
  • Hi Shawn,

    I have been able to compile it even without the intellisence and it seems to be working.

    I sometimes get the intellisence now and sometimes don't. It is wired.

    Thansk for your reply.

    Cheers

    C

    Monday, February 06, 2012 6:47 PM