Hello,

i have tree nodes built on "table per hierarchy" approach.

    public abstract class *BaseNode*
    {
        public virtual string *Name *{ get; set; }
        private string *NodeType* { get; set; }     //Discriminator Value
        public virtual BaseNode *Parent* { get; set; } //Parent can be Cat,
DomesticCat, Kitten or any other subclass that  extends BaseNode (Column
name is ParentId on db)
    }

    public class *Cat*:BaseNode  {  } //Discriminator="Cat"

    public class *DomesticCat*:BaseNode  {  } //Discriminator="DomesticCat"

    public class *Kitten*:BaseNode {  } //Discriminator="Kitten"

So, the model works great. I can get the Parent in correct subclass type for
individual nodes.

My Question is about querying them for the Parent's type;

Example: How can i query on Cats where the BaseNode's Parent's type is
DomesticCat;

HQL:
from *Cat** c *where* c.Parent.NodeType=*"DomesticCat"* *//it doesn't work
even if i change NodeType property's accessibility to "public virtual" cause
it is a discriminator value i think.

or can we do something like this;

HQL:
from *Cat** **c** *where* **c.Parent* is* *typeof(*DomesticCat*)

it is the query that i'm trying to do with HQL or better ICriteria

In SQL:
SELECT b.* FROM BaseNode b,BaseNode bParent WHERE b.ParentId=bParent.Id AND
bParent.NodeType="DomesticCat" //it is works on MSSQL

Thanks

-- 
Fethi Gürcan

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to