Hello,

I use fluent and nHibernate for about 2 months now but can not find the 
right documentation for my problem:

I habe a table "OrgUnits" wich represents a tree that can easy be queried. 
I have the following columns:

Id (Uniqueidentifier)
Name (string)
ParentOrgUnitId (uniqueidentifier)
HierarchicalPath (string - the complete path is resolved using a configured 
seperator)

I want to avoid any recursion and have a query, based on the 
HierarchicalPath column that can select all descendant org units (not only 
the children). I need this recursion-less query to resolve some connected 
ACL's (Access Control Lists).

I think there is some solution to query for all descendants in linq, but: 
How can I MAP this descendant org units. There is no Primary-Foreign Key 
relationship to all descendants. It is easy to create an SQL to query for 
all descendents (the select is cheap if you have an index in 
"HierarchicalPath":

I do not know if I can tell the fluent "HasMany" statement not to use any 
primary-foreign-key relationship but instead give some "StartsWith" on the 
HierarchicalPath column.

Here is the SQL that collects all org units I want to be returned by the 
"Descendants" mapping. This selects all descendant org units including 
"MyRoot".

Is it possible to do a mapping (self-mapping) that serves a 
IEnumerable<OrgUnit> property with all org units defined in the SQL below 
using Fluent?

select d.* from OrgUnits o
left join OrgUnits d on CharIndex(o.HierarchicalPath,d.HierarchicalPath)=1
where o.Name='MyRoot'

-- 
You received this message because you are subscribed to the Google Groups 
"Fluent NHibernate" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/fluent-nhibernate/-/I5w4iWDx9sQJ.
To post to this group, send email to fluent-nhibernate@googlegroups.com.
To unsubscribe from this group, send email to 
fluent-nhibernate+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/fluent-nhibernate?hl=en.

Reply via email to