2 u014424282 u014424282 于 2017.08.27 16:14 提问

如何把下面这段带递归公用表达式的SQL 转Linq To 10C

with subqry(DepartmentId,FullName,ParentId) as (
select DepartmentId,FullName,ParentId from Base_Department where DepartmentId in (
SELECT
[DepartmentId]
FROM [dbo].[Base_ManagementDep] where DepartmentId = '8c9ddf44-f27c-411c-9a78-2718e8f4fa31'
union
select DepartmentId from Base_User where DepartmentId='8c9ddf44-f27c-411c-9a78-2718e8f4fa31'
)
union all
select Base_Department.DepartmentId,Base_Department.FullName,Base_Department.ParentId from Base_Department,subqry
where Base_Department.ParentId = subqry.DepartmentId
)
select DepartmentId from subqry group by DepartmentId

1个回答

caozhy
caozhy   Ds   Rxr 2017.08.27 23:35

递归在linq里比较复杂,需要用自定义函数。http://www.cnblogs.com/lyj/archive/2008/03/19/1112356.html

u014424282
u014424282 大神你好:可以加你qq吗
3 个月之前 回复
Csdn user default icon
上传中...
上传图片
插入图片