Linq - 订购不订购

时间:2010-04-23 19:08:07

标签: linq linq-to-entities

我有一个linq查询,无论出于什么原因,都没有像我期望的那样回来订购。任何人都可以指出我正确的方向,为什么和我做错了什么?

代码如下:

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;

}

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

提前致谢, 比利

1 个答案:

答案 0 :(得分:3)

  

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

是的,.Where( documented可以放弃LINQ to Entities中的任何前面的.OrderBy(