2010-04-23 80 views
2

我有一个linq查询,无论出于何种原因,都不会按照我预期的那样进行排序。任何人都可以指出我正确的方向,为什么和我做错了什么?Linq - Orderby没有订购

代码如下:

List<TBLDESIGNER> designer = null; 

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

代表:

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); 

过滤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; 

    } 

过滤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; 

} 

想知道过滤是否与它有关?

由于提前, 比利

回答

3

想知道如果过滤有什么关系呢?

是的,一个是.Where(documented在LINQ上述任一.OrderBy(丢弃到实体。

+0

Thanks Craig。尽可能多的,但不知道。在某些时候,我会刷新我的linq技能。 – 2010-04-23 20:24:04