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 怎么写
这不就是一堆的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 ....
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.......}
太长了,后面自己补一下吧。
按照语法规则挨个Join:http://www.cnblogs.com/superfeeling/p/5760186.html