语法

查询表达 式必须是from 子句的开头,以select 或 group子句结束。在这两个字句之间,可以where,orderby,join,let和其它from子句

其它

AsParallel 并行查询

    Stopwatch sw = new Stopwatch();
    Stopwatch sw2 = new Stopwatch(); 
    var list = new List<Person>();
    for (int i = 0; i < 2000000; i++)
    {
      list.Add(new Person(i.ToString() + "名", "中国", i));
    }
    for (int i = 0; i < 2000000; i++)
    {
      list.Add(new Person(i.ToString() + "名", "法国", i));
    } 
    sw.Start();
    var cnums = list.AsParallel().Where(p => p.Address == "中国").Count();
    sw.Stop();
    sw2.Start();
    var cnums2 = list.Where(p => p.Address == "中国").Count();
    sw2.Stop();
    Console.WriteLine("[para方法]查找结果:" + cnums + " 共用时:" + sw.Elapsed.TotalMilliseconds);
    Console.WriteLine("[非para方法]查找结果:" + cnums2 + "共用时:" + sw2.Elapsed.TotalMilliseconds);
    Console.Read();

结论

数量超过一定级别时,使用并行查询的效果要明显好玩单行查询。