Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/drupal/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# ';System.Linq.IQueryable';不包含';GroupBy';_C#_Linq_Iqueryable - Fatal编程技术网

C# ';System.Linq.IQueryable';不包含';GroupBy';

C# ';System.Linq.IQueryable';不包含';GroupBy';,c#,linq,iqueryable,C#,Linq,Iqueryable,我遇到了一个奇怪的问题,我正在编写一个小方法来使用System.Linq.Dynamic类来查询对象列表,尽管我认为我的问题不在于动态名称空间。由于某些原因,找不到GroupBy和OrderByDescending。我已经有一个参考系统。Linq,这是我最初认为会导致这个。。。奇怪的是,它正在查找OrderBy和其他Linq方法。。我的代码如下 using System; using System.Collections.Generic; using System.Linq.Dynamic; u

我遇到了一个奇怪的问题,我正在编写一个小方法来使用System.Linq.Dynamic类来查询对象列表,尽管我认为我的问题不在于动态名称空间。由于某些原因,找不到GroupBy和OrderByDescending。我已经有一个参考系统。Linq,这是我最初认为会导致这个。。。奇怪的是,它正在查找OrderBy和其他Linq方法。。我的代码如下

using System;
using System.Collections.Generic;
using System.Linq.Dynamic;
using System.Linq;
using System.Web;

namespace MvcTemplate.jrSite.Core
{
    public static class DynamicQuery
    {
        public static IQueryable Query(IQueryable items, string where, string select, string groupby, string orderby, string orderbydesc, int take)
        {
            var ret = items;

            if (where != null && where.Length != 0)
            {
                ret = ret.Where(where);
            }

            if (select != null && select.Length != 0)
            {
                ret = ret.Select(select);
            }

            if (groupby != null && groupby.Length != 0)
            {
                ret = ret.GroupBy(groupby);
            }

            if (orderby != null && orderby.Length != 0)
            {
                ret = ret.OrderBy(orderby);
            }

            if (orderbydesc != null && orderbydesc.Length != 0)
            {
                ret = ret.OrderByDescending(orderbydesc);
            }

            return ret;
        }
    }
}

我假设您正在使用project。找不到您的方法,因为它们不存在

1) GroupBy form System.Linq.Dynamic:

public static IQueryable GroupBy(this IQueryable source, 
    string keySelector, string elementSelector, params object[] values) {
此方法需要三个参数,您的代码提供两个参数-您必须提供
elementSelector

2) 方法
OrderByDescending
甚至没有在该库的源代码中声明。和
System.Linq
也不会帮助您,因为您正在使用非通用
IQueryable
。所有扩展方法仅为强类型查询提供