Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/linq/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
Linq 连接的等效点表示法_Linq_Syntax_C# 3.0 - Fatal编程技术网

Linq 连接的等效点表示法

Linq 连接的等效点表示法,linq,syntax,c#-3.0,Linq,Syntax,C# 3.0,请告诉我这个查询的点符号。 谢谢。连接的点表示法取决于它后面的内容以及是否有“into”子句(用于组连接)。在这种情况下,它将是: string[] names = { "Burke", "Connor", "Frank", "Albert", "George", "Harris", "David" }; peoples[] people = { new peoples("Connor",20), new pe

请告诉我这个查询的点符号。
谢谢。

连接的点表示法取决于它后面的内容以及是否有“into”子句(用于组连接)。在这种情况下,它将是:

string[] names = { "Burke", "Connor", "Frank", 
   "Albert", "George", "Harris", "David" };

peoples[] people = {
                   new peoples("Connor",20),
                   new peoples("John",22),
                   new peoples("Merry",33),
                   new peoples("Frank",65),
                   new peoples("Frank",34),
                   new peoples("George",19)
               };

var query = from n in names
            join p in people on n equals p.Name into matching
            select new { Name = n, Count = matching.Count() };
  • 如果您没有使用“into”,它将使用
    Join
    而不是
    GroupJoin
  • 如果您在之后使用了除“select”之外的任何东西,它将引入一个新的透明标识符,有效地将“(n,matching)”作为元组保留
var query = names.GroupJoin(people, n => n, p => p.Name,
                   (n, matching) => new { Name = n, Count = matching.Count() });