Convert SQL to LINQ to SQL

Posted by Adam on Stack Overflow See other posts from Stack Overflow or by Adam
Published on 2010-12-27T13:49:29Z Indexed on 2010/12/27 13:53 UTC
Read the original article Hit count: 242

Filed under:
|
|
|
|

Hi

I have the SQL query

with c as (
  select  categoryId,parentId, name,0 as [level]
  from task_Category b 
  where b.parentId is null
    union all
  select b.categoryId,b.parentId,b.name,[level] + 1
  from task_Category b join c on b.parentId = 
    c.categoryId)
select name,[level],categoryId,parentId 
  as item 
from c

and I want to convert it to LINQ to SQL, yet my LINQ skills are not there yet. Could someone please help me convert this. It's the with and union statements that are making this a bit more complex for me.

Any help appreciated.

© Stack Overflow or respective owner

Related posts about c#

Related posts about .NET