首页 新闻 会员 周边 捐助

sql语句 转linq 请教 LInq 高手

0
[已解决问题] 解决于 2016-12-14 23:02

sql语句如下:

SELECT   dbo.ApplicationPermission.AreaName, dbo.ApplicationPermission.Controller, dbo.ApplicationPermission.Action, 
                dbo.ApplicationRolePermission.ApplicationRoleId, dbo.ApplicationRolePermission.ApplicationPermissionId, 
                dbo.AspNetRoles.Name, dbo.AspNetUsers.UserName
FROM      dbo.ApplicationPermission INNER JOIN
                dbo.ApplicationRolePermission ON 
                dbo.ApplicationPermission.Id = dbo.ApplicationRolePermission.ApplicationPermissionId INNER JOIN
                dbo.AspNetRoles ON dbo.ApplicationRolePermission.ApplicationRoleId = dbo.AspNetRoles.Id INNER JOIN
                dbo.AspNetUserRoles ON dbo.AspNetRoles.Id = dbo.AspNetUserRoles.RoleId INNER JOIN
                dbo.AspNetUsers ON dbo.AspNetUserRoles.UserId = dbo.AspNetUsers.Id
WHERE   (dbo.AspNetUsers.UserName = N'283868910@qq.com')

转为linq 怎么写

SpeakHero的主页 SpeakHero | 初学一级 | 园豆:31
提问于:2016-12-14 01:43
< >
分享
最佳答案
0

这不就是一堆的INNER JOIN +WHERE么?

var q= from c in TableA

          join d in TableB on TableA.ID=TableB.ID

          join e in TableC on ...

          join f in TableD on ...

          where ....

奖励园豆:5
爱编程的大叔 | 高人七级 |园豆:30844 | 2016-12-14 10:13
其他回答(2)
1

from ap in applicationPermission

join  arp in applicationRolePermission

on ap.Id equals arp.ApplicationPermissionId

from anr in aspNetRoles

join arp2 in applicationRolePermission

on anr.Id equals arp2.ApplicationRoleId

from anur in aspNetUserRoles

join anr2 in aspNetRoles

on anur.RoleId equals anr2.Id

from anu in aspNetUsers

join anur2 in aspNetUserRoles

on anu.Id equals anur2.UserId

where anu.UserName =='283868910@qq.com'

select new {AreaName=ap.AreaName,Controller=ap.Controller,Action=ap.Action.......}

太长了,后面自己补一下吧。

Daniel Cai | 园豆:10424 (专家六级) | 2016-12-14 09:19
0

按照语法规则挨个Join:http://www.cnblogs.com/superfeeling/p/5760186.html

静以修身俭以养德 | 园豆:219 (菜鸟二级) | 2016-12-14 22:59
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册