首页 > 其他分享 >LINQ:Group Join

LINQ:Group Join

时间:2022-08-24 17:23:44浏览次数:53  
标签:Console Group addr LINQ item WriteLine var Join ADDEmp

1.代码

//group join
            var groupJoinQS = from addr in Address.GetAddress()
                              join emp in Employee.GetAllEmployees() on addr.ID equals emp.AddressId into ADDEmp
                              select new { addr, ADDEmp };
            foreach (var item in groupJoinQS)
            {
                Console.WriteLine(item.addr);
                Console.WriteLine(item.ADDEmp);
                Console.WriteLine(item.addr.AddressLine);
                foreach (var employee in item.ADDEmp)
                {
                    Console.WriteLine("  EmployeeID : " + employee.ID + " , Name : " + employee.Name);
                }
            }

2.测试结果如下

 

 所以ADDEmp指的是Employee?

参考:

https://dotnettutorials.net/lesson/linq-group-join/

标签:Console,Group,addr,LINQ,item,WriteLine,var,Join,ADDEmp
From: https://www.cnblogs.com/keeplearningandsharing/p/16620922.html

相关文章

  • Linq-面试题
    1.用逗号分隔表示成绩的字符串,计算成绩的平均值//10,60,30,20,70,90stringstr="10,60,30,20,70,90";string[]strs=str.Split(',');IEnumerable<int>nums=strs......
  • LINQ 左连接(Left Join)
     1.数据准备usingSystem.Collections.Generic;namespaceLINQTutorial{publicclassEmployee{publicintID{get;set;}publics......
  • springboot+mybatis-plus-join+mysql实现连表查询
    1.简介  Mybatis是目前比较主流的持久层框架,使用非常广泛。Mybatis-Plus是基于Mybatis增强工具包,越来越受到开发人员的喜爱。  在使用Mybatis-Plus开发时,简单的crud......
  • Lambda方式左连接有Linq方式左连接
    http://t.zoukankan.com/superfeeling-p-7530549.htmlhttps://blog.csdn.net/qq_22325259/article/details/121545038 网上查到的直接使用Join+DefaultIfEmpty的方式是......
  • 记C# 通过JObject 读取 json对象(Newtonsoft.Json.Linq.JObject.this[string].get 返回
    json对象"RequestHeaders":{ "Host":"tool.kkbmtj.com", "Referer":"https://m.kkbmtj.com/ys/shortindex?origin=kktj&xcx", }代码:HeaderLogheaderLog......
  • Yii2 ElasticSearch aggregate (group)
    我想要统计的是country_code出现的次数,通过yii2的ElasticSearch扩展,上面的例子满足我的需要。业务场景:在fecify商城中,使用elasticSearch搜索,进行aggregategrou......
  • 结构体数组使用StructLinq
    .NET性能优化-为结构体数组使用StructLinq 前言本系列的主要目的是告诉大家在遇到性能问题时,有哪些方案可以去优化;并不是要求大家一开始就使用这些方案来提升性能。......
  • What does Include() do in LINQ?
    WhatdoesInclude()doinLINQ?问题ItriedtodoalotofresearchbutI'mmoreofadbguy-soeventheexplanationintheMSDNdoesn'tmakeanysensetom......
  • sql语句左链接left join--3张表关联
    表A---------------------------------关联第一张表B-----------------------关联第二张表cselect*from表名Aleftjoin 表B  on  表A字段=表B的idlef......
  • CAD二次开发---关于JoinEntity出现eNotApplicable的问题
    作者在使用JoinEntity时出现eNotApplicable的问题,查阅了Autodesk论坛的相关帖子,发现大多数人都有遇到这个问题,但没有找到合适的解决方法,可能原因是进行Join时两Curve需要同......