Click here to Skip to main content
15,042,336 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi Every one

I am developing a website where i have used entity framework data model. Now the problem is that in my data base, i have a CTE table created using view

My Query to develop the query is as under

SQL
WITH cte(categoryid, categorytitle, categoryparent, categorydetail,categorycreationdate,categoryinsertedby, categorystatus, companyid, lang)AS (SELECT categoryid,CAST(categorytitle AS VARCHAR(MAX)) AS expr1,categoryparent,categorydetail,categorycreationdate,categoryinsertedby,categorystatus,companyid,lang FROM   dbo.tbl_categories WHERE ( categoryparent = 0 or categoryparent is null)AND ( categorystatus = 1 )UNION ALL SELECT p.categoryid,CAST(c.categorytitle + '>> ' + p.categorytitle AS VARCHAR(MAX)) AS expr1,p.categoryparent,p.categorydetail,p.categorycreationdate,p.categoryinsertedby,p.categorystatus,p.companyid,p.lang FROM   dbo.tbl_categories AS p INNER JOIN cte AS c ON c.categoryid = p.categoryparent) SELECT TOP (100) PERCENT categorytitle, categoryparent,categorydetail, categorycreationdate,categoryinsertedby,categorystatus,companyid, lang,categoryid FROM   cte AS cte_1 ORDER  BY categorytitle ")


The Table from which i am generating this query is tbl_Categories
I want the equivalent linq statement for the above query.
Regards
TanzeelurRehman
Posted
Comments
Amir Mahfoozi 26-Jan-12 6:02am
   
Lets put on a trick : http://msdn.microsoft.com/en-us/library/bb399403.aspx

1 solution

   
Comments
Uday P.Singh 26-Jan-12 4:37am
   
5 for the very nice link :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900