A very simple scenario.
I have 2 classes: *Project* and *DataStructure*. Class *Project*
contains member List<DataStructure>.
My goal is to load a single *Project* object and all its
DataStructures in one call.

    public class Project
    {
        public virtual string Id { get { } set { } }
        public virtual string Name { get { } set { } }
        public virtual ISet<DataStructure> DataStructures { get { }
set { } }
    }

    public class DataStructure
    {
        public virtual string Id { get { } set { } }
        public virtual string Name { get { } set { } }
        public virtual string Description { get { } set { } }
        public virtual Project Project { get { } set { } }
        public virtual IList<DataField> Fields { get { } set { } }
    }

Note that *DataStructure* also contains a list of class *DataField*
but I don’t want to load these right now.

Mapping in Fluent NHibernate:

    public class ProjectMap : ClassMap<Project>
    {
        public ProjectMap()
        {
            Table("PROJECTS");
            Id(x => x.Pk, "PK");
            Map(x => x.Id, "ID");
            Map(x => x.Name, "NAME");
            HasMany<DataStructure>(x =>
x.DataStructures).KeyColumn("FK_PROJECT");
        }
    }

    public class DataStructureMap : ClassMap<DataStructure>
    {
        public DataStructureMap()
        {
            Table("DATA_STRUCTURES");
            Map(x => x.Id, "ID");
            Map(x => x.Name, "NAME");
            Map(x => x.Description, "DESCRIPTION");
            References<Project>(x => x.Project, "FK_PROJECT");
            HasMany<DataField>(x =>
x.Fields).KeyColumn("FK_DATA_STRUCTURE");
        }
    }

This is my query:

    using (ISession session = SessionFactory.OpenSession())
    {
        IQuery query = session.CreateQuery("from Project left join
Project.DataStructures");
        project = query.List<Project>();
    }

The result is this exception:

NHibernate.Hql.Ast.ANTLR.InvalidPathException: Invalid path:
'Project.DataStructures' [from Themis.DataEntities.Project left join
Project.DataStructures]

How do I declare the left join?

Note1 – Table *PROJECTS* contains a single *Project* row so there is
no need to search for a specific one.

Note2 – I verified that my NHibernate setup is correct by successfully
loading just the *Project*.

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

Reply via email to