且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

用于自引用表的 LINQ to SQL?

更新时间:2023-02-02 23:02:48

我不认为 linq-to-sql 对这个问题有很好的答案.由于您使用的是 sql server 2005,因此您可以使用 CTE 进行分层查询.存储过程或内联查询(使用 DataContext.ExecuteQuery)都可以解决问题.

I don't think linq-to-sql has a good answer to this problem. Since you are using sql server 2005 you can use CTEs to do hierarchical queries. Either a stored procedure or an inline query (using DataContext.ExecuteQuery) will do the trick.