where是限制操作符,它将过滤标准应用在序列上,按照提供的逻辑对序列中的数据进行过滤。

where操作符不启动查询的执行。当开始对序列进行遍历时才开始执行,此时过滤条件将被应用到查询中。

示例:

//where限制操作符:使用延迟加载
var q = teachers.SelectMany(p => p.Students).Where(s => s.Score < 60).Select(a => new { name = a.Name });
foreach (var item in q)
{
     Console.WriteLine("姓名:"+item.name);
}

 

相关文章:

  • 2021-08-12
  • 2021-08-10
  • 2021-11-17
  • 2021-07-16
  • 2021-07-18
  • 2022-12-23
猜你喜欢
  • 2021-09-22
  • 2021-12-27
  • 2021-10-01
  • 2021-07-08
  • 2021-10-21
  • 2021-10-10
  • 2021-10-27
相关资源
相似解决方案