首页 > 数据库技术 > 详细

sql 与linq的转换

时间:2015-07-23 17:13:59      阅读:244      评论:0      收藏:0      [点我收藏+]

1. left Join

原始sql

select  t.[MINTAccountIdentifier] from BSS_Tenant  t left join
 BL_SAPCustomer s on  s.BillableAccountID=t.MINTAccountIdentifier where s.CustomerID is null;


转化的linq

from t in entities.BSS_Tenant
 join s in entities.BL_SAPCustomer on t.MINTAccountIdentifier equals s.BillableAccountID into osy
  from os in osy.DefaultIfEmpty()
  where os.CustomerID == null
  select t.MINTAccountIdentifier;

生成的sql

SELECT 
    [Extent1].[MINTAccountIdentifier] AS [MINTAccountIdentifier]
    FROM  [dbo].[BSS_Tenant] AS [Extent1]
    LEFT OUTER JOIN [dbo].[BL_SAPCustomer] AS [Extent2] ON [Extent1].[MINTAccountIdentifier] = [Extent2].[BillableAccountID]
    WHERE [Extent2].[CustomerID] IS NULL


 

 

sql 与linq的转换

原文:http://www.cnblogs.com/sunShineJing/p/4670897.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!