hierarchyid

How do you get all ancestors of a node using SQL Server 2008 hierarchyid?

[亡魂溺海] 提交于 2019-11-28 16:00:37
问题 Given a table with a hierarchyid type column, how do you write a query to return all rows that are ancestors of a specific node? There is an IsDescendantOf() function, which is perfect for getting the children, but there's no corresponding IsAncestorOf() function to return ancestors (and the absence of a GetAncestors() function seems like quite an oversight.) 回答1: The most commonly used approach would be a recursive Common Table Expression (CTE) WITH Ancestors(Id, [Name], AncestorId) AS (

SQL 2008 HierarchyID support in NHibernate

…衆ロ難τιáo~ 提交于 2019-11-27 17:19:38
问题 Searched various NHibernate lists and haven't come up with a definitive answer. The SQL2008 dialect doesn't appear to have support for the HierarchyID data type - new date and time types only. Does anyone have a good implementation or an effective workaround? I'd really like to leverage HierarchyID in a new app of mine. Support for this interesting and powerful data type is sorely lacking in MS's own tools so I'm not shocked that NHibernate doesn't have support. There are some approaches out

HierarchyID in Entity Framework not working

一曲冷凌霜 提交于 2019-11-27 10:24:40
问题 We are using WCF Data Service based on an Entity Framework model for our application. In this we need to add the table with a column of type HierarchyId . When I add that table to the EDMX file, the HierarchId column is not appearing in the class file. What should I do to make use of HierarchyID ? I read that Entity Framework is not supporting HierarchyID , so how can I achieve this? 回答1: You can always convert a HierarchyId to its string representation - something like /1/3/4/1 - and send