verwendetes Datenbanksystem: MS SQL Server 2008
Ich erarbeite mir gerade anhand eines Nested Set SQL Tutorials eine DB und versuche nun das lese Statement in Linq umzuwandeln, aber das sieht nicht aus wie das handelsübliche SQL. Könnte mir jemand helfen?
Mein Ansatz:
Was mir also noch fehlt ist das "COUNT(*)-1 AS level" und das "GROUP BY n.lft" und ob der rest richtig ist, ist auch die Frage
Danke im vorraus
Ich erarbeite mir gerade anhand eines Nested Set SQL Tutorials eine DB und versuche nun das lese Statement in Linq umzuwandeln, aber das sieht nicht aus wie das handelsübliche SQL. Könnte mir jemand helfen?
Code:
SELECT n.name, COUNT(*)-1 AS level FROM tree AS n, tree AS p WHERE n.lft BETWEEN p.lft AND p.rgt GROUP BY n.lft ORDER BY n.lft;
Mein Ansatz:
Code:
var tree = from n in db.Categories from p in db.Categories where n.Lft >= p.Lft && n.Rgt <= p.Rgt orderby n.Lft select new { name = n.Name, level = "" };
Was mir also noch fehlt ist das "COUNT(*)-1 AS level" und das "GROUP BY n.lft" und ob der rest richtig ist, ist auch die Frage
Danke im vorraus