Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/330.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/go/7.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# 将IQueryable作为IEnumerable调用,是否在客户端完成筛选?_C#_Iqueryable - Fatal编程技术网

C# 将IQueryable作为IEnumerable调用,是否在客户端完成筛选?

C# 将IQueryable作为IEnumerable调用,是否在客户端完成筛选?,c#,iqueryable,C#,Iqueryable,我在这里读一篇文章: 我遇到了下面的语句“zombieRepository.GetAll().Where(funcomp)”,GetAll()返回一个IQueryable,但是Where语句在Func参数中传递,该参数实际上将IQueryable接口作为IEnumerable接口调用 此调用的问题是,筛选器是在客户端完成的(读取所有dto.ZombieIncidentout,然后应用筛选器),而不是在sql server端完成的,我的理解正确吗 代码段: var paramStart = Exp

我在这里读一篇文章:

我遇到了下面的语句“zombieRepository.GetAll().Where(funcomp)”,
GetAll()
返回一个
IQueryable
,但是
Where
语句在
Func
参数中传递,该参数实际上将
IQueryable
接口作为
IEnumerable
接口调用

此调用的问题是,筛选器是在客户端完成的(读取所有
dto.ZombieIncident
out,然后应用筛选器),而不是在sql server端完成的,我的理解正确吗

代码段:

var paramStart = Expression.Parameter(typeof(dtos.ZombieIncident), "x");
                Expression<Func<dtos.ZombieIncident, bool>> func = Expression.Lambda<Func<dtos.ZombieIncident, bool>>(
                            Expression.Call(Expression.Property(paramStart,
                                typeof(dtos.ZombieIncident).GetProperty(propertyName).GetGetMethod()),
                                typeof(String).GetMethod(searchType.ToString(), new Type[] { typeof(String) }),
                                new Expression[] { Expression.Constant(searchValue, typeof(string)) }),
                    new ParameterExpression[] { paramStart });

                Func<dtos.ZombieIncident, bool> funcComp = func.Compile();

                foreach (dtos.ZombieIncident zombie in zombieRepository.GetAll().Where(funcComp).ToList())
                {
                    zombies.Add(ZombieIncidentDTOMapper.FromDTO(zombie));
                }
var paramStart=Expression.Parameter(typeof(dtos.ZombieIncident),“x”);
表达式func=Expression.Lambda(
Expression.Call(Expression.Property(paramStart,
typeof(dtos.ZombieIncident).GetProperty(propertyName.GetMethod()),
typeof(String).GetMethod(searchType.ToString(),新类型[]{typeof(String)}),
新表达式[]{Expression.Constant(searchValue,typeof(string))}),
新参数表达式[]{paramStart});
Func funcomp=Func.Compile();
foreach(zombieRepository.GetAll()中的dtos.ZombieIncident zombie.Where(funcomp.ToList())
{
添加(zombieincidenttomapper.FromDTO(zombie));
}

有两种不同的
扩展方法:

:

  • 接受
    Func
    参数
  • 筛选内存中的集合
:

  • 接受
    表达式
    参数
  • 在数据源处筛选集合

如果不确定使用的是哪种方法,请将光标放在该方法上并按F1。您将被发送到与上述链接之一对应的页面。

有两种不同的
扩展方法:

:

  • 接受
    Func
    参数
  • 筛选内存中的集合
:

  • 接受
    表达式
    参数
  • 在数据源处筛选集合

如果不确定使用的是哪种方法,请将光标放在该方法上并按F1。您将被发送到与上述链接之一对应的页面。

检查您的标题(可编辑:)或IQueryable?不确定僵尸是否有一些特殊的接口…@AlexeiLevenkov,updated你有sql分析器吗?如果是这样,运行它,它将告诉您实际查询在做什么。在快速查看代码时,它看起来像是在数据库端进行查询。请检查标题ICurable:)或IQueryable?不确定僵尸是否有一些特殊的接口…@AlexeiLevenkov,updated你有sql分析器吗?如果是这样,运行它,它将告诉您实际查询在做什么。在快速查看代码时,它看起来像是在数据库端进行查询。