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() });