Thanks for your help James.  I knew about the new syntax stuff and
have a plan to move over to it already.

And... I also read your blog post and managed to completely ignore
it!  that worked a treat.

Below is corrected code that works fine, just in case anyone is
interested.

      DiscriminateSubClassesOnColumn<string>("userType")
        .SubClass<TypeAUser>()
        .IsIdentifiedBy("A")
        .MapSubClassColumns(x => x.References(g => g.TypeA)
                .TheColumnNameIs("userTypeID")
                .Cascade.SaveUpdate())
        .SubClass<TypeBUser>()
        .IsIdentifiedBy("B")
          .MapSubClassColumns(x => x.References(g => g.TypeB)
                .TheColumnNameIs("userTypeID")
                .Cascade.SaveUpdate();

Thanks a lot for your help, and keep up the great work with fluent!

Cheers,
Chris
On Jan 29, 3:44 pm, James Gregory <jagregory....@gmail.com> wrote:
> Firstly, I can tell by your code that you're on an older version of Fluent
> NHibernate - I'd advise updating as the join stuff has changed.
> You should read this for the join syntax changes: Fluent NHibernate SubClass
> syntax 
> changes<http://blog.jagregory.com/2009/01/05/fluent-nhibernate-subclass-synta...>
>
> Then have a read on this: I think you mean a many-to-one
> sir<http://blog.jagregory.com/2009/01/27/i-think-you-mean-a-many-to-one-sir/>
>
> Your code looks almost right except you're using HasOne which creates a
> one-to-one relationship when really you need a many-to-one, which is the
> References method.
>
> James
>
> On Thu, Jan 29, 2009 at 2:41 PM, chris <bikk...@gmail.com> wrote:
>
> > Hi all,
> > I have the following scenario that I'm struggling to map out in
> > fluent.  Can anyone advise?
>
> > Tables:
> > =======
> > TypeA
> > TypeB
> > User
>
> > Relationships:
> > ===========
> > User table has a "type" discriminator column and a "typeID" so when
> > the type column is A the typeID will point to the TypeA subtable.
>
> > What I would like is for a many-to-one TypeA object be part of my
> > subclass.
>
> > Thanks,
> > Chris
>
> > public User {
> >   int ID {get;set;}
> >   string Name {get;set;}
> >   string PasswordHash {get:set;}
> >   string Type {get;set;}
> > }
>
> > public TypeAUser : User {
> >    TypeA TypeA {get; set;}
> > }
>
> > public TypeBUser : User {
> >   TypeB TypeB {get;set;}
> > }
>
> >  public class UserMap : ClassMap<User>
> >  {
> >    public UserMap()
> >    {
> >      WithTable("Users");
>
> >      Id(x => x.ID, "userID").GeneratedBy.Identity();
>
> >      Map(x => x.Name, "userName");
> >      Map(x => x.PasswordHash, "userPasswordHash");
> >      Map(x => x.Salt, "userSalt");
> >      Map(x => x.Type, "userType").AsReadOnly();
>
> >      DiscriminateSubClassesOnColumn<string>("userType")
> >        .SubClass<TypeAUser>()
> >            .IsIdentifiedBy("G")
> >            .MapSubClassColumns(x => x.HasOne(g => g.TypeA))
> >        .SubClass<TypeBUser>()
> >        .IsIdentifiedBy("P")
> >        .MapSubClassColumns(x => x.HasOne(g => g.TypeB)
> >        );
> >    }
> >  }

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Fluent NHibernate" group.
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