Thanks everyone, i'm also thought that mapping in separate classes
will be the solution, I just wanted to be sure that ther is no other
way.

On Jan 6, 4:38 pm, Hudson Akridge <hudson.akri...@gmail.com> wrote:
> > How can I define that the related column in the CUSTOMER table will be
> > CustomerTypeCode and not CustomerId? (if I can at all)
>
> I don't believe you can. The table you're performing a join on uses the PK,
> while the table you're joining to can be defined by a KeyColumn. 
> Ref:http://ayende.com/Blog/archive/2009/04/20/nhibernate-mapping-ltjoingt...
>
> What it really looks like you're trying to do here, is a Many-To-One
> (References() in FNH). I would recommend a mapping class for CustomerType,
> as a class, and define the Id(x=> x.CustomerType). Then map a References(x=>
> x.CustomerType, "CustomerTypeCode") on the Customer side. This should give
> you what you want. A Join is for when you have two tables, that contain the
> same information for an object. In this case, Customer, and CustomerType
> should be two separate classes in your object model. Doing that will allow
> you to represent them in FNH/NH much easier.
>
>
>
>
>
> On Wed, Jan 6, 2010 at 6:53 AM, Paul Batum <paul.ba...@gmail.com> wrote:
> > I can't find anything in the nhibernate documentation that indicates
> > how you would do this with the xml. You might be best served asking on
> > the nhusers list to determine the necessary xml so that we can then
> > help you map it with FNH.
>
> > On Wed, Jan 6, 2010 at 11:25 PM, Olga <olgaru...@gmail.com> wrote:
> > > Hello,
>
> > > I have two tables that I want to map to one class that will looks
> > > like:
>
> > > CUSTOMER_INFO_CLASS.cs
> > > ----------------------
> > > Id (CUSTOMER table)
> > > CustomerName (CUSTOMER table)
> > > CustomerTypeDesc (CUSTOMER_TYPE table)
> > > I tried to do it with join, as follows:
>
> > > Table("CUSTOMER");
>
> > > Id(x => x.ID).Length(10).Column("CustomerId");
> > > Map(x => x.CustomerName);
>
> > > Join("CUSTOMER_TYPE", m =>
> > >    {
> > >    m.Optional();
> > >    m.Map(x => x.CustomerTypeDesc);
> > >    m.KeyColumn("CustomerType");
> > >    });
> > > The problem is that the field with whom I'm trying to link the two
> > > tables is not a primary key in any of them. (And by default the join
> > > done by the field that defined as ID) So I found that for the
> > > CUSTOMER_TYPE table I can define the field by “KeyColumn”.
> > > How can I define that the related column in the CUSTOMER table will be
> > > CustomerTypeCode and not CustomerId? (if I can at all)
>
> > > At the end the sql query should looks like:
>
> > > Select Id, CustomerName, CustomerAddress, CustomerTypeDesc
> > > From CUSTOMER t1
> > >  Left join CUSTOMER_TYPE t2
> > >    On t1.CustomerTypeCode = t2.CustomerType
>
> > > --
> > > 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<fluent-nhibernate%2bunsubscr­...@googlegroups.com>
> > .
> > > For more options, visit this group at
> >http://groups.google.com/group/fluent-nhibernate?hl=en.
>
> > --
> > 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<fluent-nhibernate%2bunsubscr­...@googlegroups.com>
> > .
> > For more options, visit this group at
> >http://groups.google.com/group/fluent-nhibernate?hl=en.
>
> --
> - Hudsonhttp://www.bestguesstheory.comhttp://twitter.com/HudsonAkridge- Hide 
> quoted text -
>
> - Show quoted text -
-- 
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