I've got a set of mappings like this: public class UserMap :
ClassMap<User>
{
    public UserMap()
    {
        Map(x => x.Id);
        Map(x => x.Status);
    }
}

public class SpecialUserMap : SubClassMap<User>
{
    public SpecialUserMap()
    {
        Map(x => x.Property);
    }
}

public class DirectoryMap : ClassMap<Directory>
{
    public DirectoryMap
    {
        Map(x => x.Id);
        HasMany(x => x.SpecialUsers).Where("Status = 0");
    }
}

where User is a join map, and SpecialUser joins against it to get
things like Status. I can't get the DirectoryMap to work, since
accessing Directory's SpecialUsers collection causes a "undefined
column Status" error, as NHibernate can't figure out that the Status
column comes from the User table, and not the SpecialUser table.
Is there a way to manually tell NHibernate which column to look at?

Another possible solution I thought of is to throw a subselect SQL
statement into the Where clause, but NHibernate tends to do this:

Where("SELECT u.Status FROM User WHERE u.Id = Id) generates select
<columns> from [SpecialUser] specialuse0_ inner join [User]
specialuse0_1_ on <id = id> WHERE (SELECT u.Status FROM
specialuse0_.Status = 0)

Basically it treats my variables as columns from the SpecialUser
table, and inserts specialuse0_ into the SQL instead.
If there is a way to make NHibernate not touch the SQL inserted in the
Where clause that might be a possible solution (albeit not a good one)
as well.

--

You received this message because you are subscribed to the Google Groups 
"Fluent NHibernate" 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/fluent-nhibernate?hl=en.


Reply via email to