I have a seemingly simple join that I can't seem to get working
properly--more specifically, the join works, and my child object is
properly assembled--but I get the wrong value.  I'm sure this is a
case of my not wholly grokking what's the appropriate mapping
mechanism for different contexts.

I'll use Addresses to illustrate.

public class Address {
    //usual suspects
    State State;
}

public class State {
   [Id, Name, Shortname]
}

--
I've tried several different ways of mapping this, as I don't think I
fully understand what distinguishes each.  Component(),
HasOne<State>(), ReferencesAny<State>() all ultimately ended up with
runtime exceptions.  I believe what I'm after is a simple Join(), but
as I stated, I'm getting a properly assembled State value, but it's
the wrong value.  It's always the very first record in the State table
regardless of the value in my StateID column in the Address table.

My mapping as it stands now:
public AddressMap()
{
    Id(a => a.Id).Column("AddressID").GeneratedBy.Identity();
    Map(a => a.City);
    Map(a => a.PostalCode);
    Map(a => a.Street1);
    Map(a => a.Street2);

    Join("State", join =>
    {
        join.KeyColumn("StateID");
        join.Component(a => a.State, m =>
        {
            m.Map(x => x.Id).Column("StateID");
            m.Map(x => x.Name);
            m.Map(x => x.ShortName).Column("ISO2");
        });
     });
}

My presumption is that join.KeyColumn("StateID") is analogous to the
ON clause of a JOIN statement.  But it's not what I'm observing at the
moment.

-- 
You received this message because you are subscribed to the Google Groups 
"Fluent NHibernate" group.
To post to this group, send email to fluent-nhibern...@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