FineUI 官方论坛
标题:
EF语句转换
[打印本页]
作者:
shouzhi2007
时间:
2014-4-14 14:15
标题:
EF语句转换
SELECT u.ChineseName,u.Name,d.Name,t2.Name FROM dbo.Users u
LEFT JOIN dbo.Depts d ON u.DeptID = d.ID
LEFT JOIN dbo.TitleUsers t ON u.ID = t.UserID
LEFT JOIN dbo.Titles t2 ON t.TitleID = t2.ID
ORDER BY t2.Name desc
复制代码
这语句怎么用
IQueryable
复制代码
写出来?
作者:
gdcrx
时间:
2014-4-15 11:19
我没创建表测试,下面语句你看下生成的sql语句是否可行。
var sel = from u in dbo.Users
join d in dbo.Depts on u.DeptID equals d.ID into dept
from d_d in dept.DefaultIfEmpty()
join t in dbo.TitleUsers on u.ID equals t.UserID into title1
from d_t in title1.DefaultIfEmpty()
join t2 in dbo.Titles on d_t.TitleID equals t2.ID into tile2
from d_t2 in tile2.DefaultIfEmpty()
orderby d_t2.Name
select new {
ChineseName = u.ChineseName,
Name=u.Name,
DeptName = (d_d.DeptID == null) ? string.Empty : d_d.Name,
TitleName = (d_t2.ID == null)? string.Empty : d_t2.Name
};
复制代码
欢迎光临 FineUI 官方论坛 (https://fineui.com/BBS/)
Powered by Discuz! X3.4