如何把下面这段带递归公用表达式的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个回答

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

u014424282
放开那段代码让我来 大神你好:可以加你qq吗
2 年多之前 回复
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问