views:

44

answers:

1

Hello everyone, I have a linq query that for whatever reason is not coming back ordered as i would expect it to. Can anyone point me in the right direction as to why and what i am doing wrong?

Code is as follows:

List<TBLDESIGNER> designer = null;

using (SOAE strikeOffContext = new SOAE())
{
   //Invoke the query
   designer = AdminDelegates.selectDesignerDesigns.Invoke(strikeOffContext).ByActive(active).ByAdmin(admin).ToList();
}

Delegate:

public static Func<SOAE, IQueryable<TBLDESIGNER>> selectDesignerDesigns =
        CompiledQuery.Compile<SOAE, IQueryable<TBLDESIGNER>>(
        (designer) => from c in designer.TBLDESIGNER.Include("TBLDESIGN")
                      orderby c.FIRST_NAME ascending
                      select c);

Filter ByActive:

public static IQueryable<TBLDESIGNER> ByActive(this IQueryable<TBLDESIGNER> qry, bool active)
    {
        //Return the filtered IQueryable object
        return from c in qry
               where c.ACTIVE == active
               select c;

    }

Filter ByAdmin:

public static IQueryable<TBLDESIGNER> ByAdmin(this IQueryable<TBLDESIGNER> qry, bool admin)
{
    //Return the filtered IQueryable object
    return from c in qry
           where c.SITE_ADMIN == admin
           select c;

}

Wondering if the filtering has anything to do with it??

Thanks in advance, Billy

+2  A: 

Wondering if the filtering has anything to do with it??

Yes, a .Where( is documented to discard any preceding .OrderBy( in LINQ to Entities.

Craig Stuntz
Thanks Craig. Figured as much, but wasn't sure. At some point i will brush up on my linq skills.
Billy Logan