1、左连接:

var LeftJoin = from emp in ListOfEmployees
join dept in ListOfDepartment
on emp.DeptID equals dept.ID into JoinedEmpDept
from dept in JoinedEmpDept.DefaultIfEmpty()
select
new

{
EmployeeName = emp.Name,
DepartmentName = dept != null ? dept.Name :
null

};

 

2、右连接:

var RightJoin = from dept in
ListOfDepartment
join employee in ListOfEmployees
on dept.ID equals employee.DeptID into joinDeptEmp
from employee in joinDeptEmp.DefaultIfEmpty()
select
new

{
EmployeeName = employee != null ? employee.Name : null,
DepartmentName = dept.Name
};

 

3、内连接:

 var query = from t in
entitiy.TB_GCGL_ADA_USER
                
join p in entitiy.TB_GCGL_ZY_ZYK
                
on t.ETPRS_CODE equals p.ETPRS_CODE

                
select new TB_USER_ZYK
                
{
                   
USER_ID = t.USER_ID,
                   
USER_NAME = t.USER_NAME,
                   
USER_PASSWORD = t.USER_PASSWORD,

                
};

Linq左关联 右关联 内关联的更多相关文章

  1. mysql左连接 右连接 内连接的区别

    mysql左连接 右连接 内连接的区别 1.内连接,显示两个表中有联系的所有数据; 2.左链接,以左表为参照,显示所有数据,右表中没有则以null显示 3.右链接,以右表为参照显示数据,,左表中没有则 ...

  2. linq的左连接右连接内连接用法

    1.左连接: var LeftJoin = from e in ListOfEmployees join d in ListOfDepartment on e.DeptID equals d.ID i ...

  3. mysql中的左连接右连接内连接

    一. 初始化SQL语句 /*join 建表语句*/ drop database if exists test; create database test; use test; /* 左表t1*/ dr ...

  4. PHP左、右、内连接

    left join   :左连接,返回左表中所有的记录以及右表中连接字段相等的记录.right join :右连接,返回右表中所有的记录以及左表中连接字段相等的记录.inner join: 内连接,又 ...

  5. mysql 左连接 右连接 内链接

    一般所说的左连接,右连接是指左外连接,右外连接.做个简单的测试你看吧.先说左外连接和右外连接:[TEST1@orcl#16-12月-11] SQL>select * from t1;ID NAM ...

  6. Mysql之左连接右连接内连接——示例 (转)

    下面是两张表 表stu 表tech 1.右连接 当使用右连接语句查询时,返回结果如下: 1 SELECT stu.id,stu.name,stu.classe_name,tech.id,tech.na ...

  7. 关于数据库的左,右,内,外连接,Union和Union all---------笔记

    1.左连接 select a.filed1,a.filed2,b.filed1 from a (左表) left join b(右表) on a.commonfiled = b.commonfiled ...

  8. ORACLE 左连接 右连接 内连接 外连接 全连接 五中表连接方式

    1.左连接 :left join 2.右连接:right join 3.内连接:inner join 4.外连接:outer join 5.全连接:full join

  9. mysql左连接,右连接,内连接

  10. linq to entity 左连接 右连接 以及内连接写法的区别

    左连右连还是内连这个其实你不需要关心.只需要根据实体的映射关系写查询,框架会自动帮你生成的. 至于linq查询语法与扩展方法的效率,应该是一样的,比如: var users=(from u in db ...

随机推荐

  1. rabbitmq用于分布式系统

    上文介绍了RabbitMQ在linux下的安装,这里就简单的介绍一下基于RabbitMQ的开发.RabbitMQ已经提供了一大坨材料. Java – http://www.RabbitMQ.com/j ...

  2. PAT (Advanced Level) 1104. Sum of Number Segments (20)

    简单题. #include<cstdio> #include<cstring> #include<cmath> #include<vector> #in ...

  3. JS中substr和substring的用法和区别

    substr 和 substring都是JS 截取字符串函数,两者用法很相近,下面是两者的语法很示例: substr 方法 返回一个从指定位置开始的指定长度的子字符串.stringvar.substr ...

  4. RTC-高效率实现TimerTicker编解码

    源:RTC-高效率实现TimerTicker编解码 嵌入式系统中时间是很重要的,在以往的系统中设计者常常使用一种叫RTC的专用芯片来维持时间,这种芯片种类很多接口形式也很多,如常用的DS1302.PC ...

  5. struts1.x中web.xml文件的配置

    1.配置欢迎文件清单      当客户访问Web应用时,如果仅仅给出Web应用的Root URL,没有指定具体的文件名.Web容器会自动调用Web应用的欢迎文件.<welcome-file-li ...

  6. Beautiful Subarrays

    Beautiful Subarrays time limit per test 3 seconds memory limit per test 512 megabytes input standard ...

  7. CentOS 6.5 安装Nvidia驱动后出现"no screens found "错误

    参考官网文档 http://cn.download.nvidia.com/XFree86/Linux-x86_64/280.13/README/editxconfig.html 进入更改文档: vi ...

  8. PAT (Advanced Level) 1077. Kuchiguse (20)

    最长公共后缀.暴力. #include<cstdio> #include<cstring> #include<cmath> #include<vector&g ...

  9. .htaccess 保护文件夹

    想要保护admin文件夹,经过以下两个步骤: 步骤一.可以用记事本新建文件.htaccess,输入以下内容: AuthType BasicAuth UserFile D:/AppServ/www/Hi ...

  10. base库--- 一个应用JS

    1 /** * Created by Administrator on 2014/6/3 0003. */ $(function () { //个人中心下拉 $('.js-hd-right').hov ...