Point equivalent for JOIN

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

Please tell me the exact notation of this request. Thank.

+3
source share
1 answer

The dot notation for a join depends on what follows and if you have a “in” clause (for a group join). In this case, it will be:

var query = names.GroupJoin(people, n => n, p => p.Name,
                   (n, matching) => new { Name = n, Count = matching.Count() });
  • If you didn’t use “in,” he would use JoininsteadGroupJoin
  • If you had something other than just “pick” after that, it would introduce a new transparent identifier to effectively “(n, matching)” as a tuple.
+2
source

Source: https://habr.com/ru/post/1764476/


All Articles