We are trying to get the "Entity spanning multiple tables" to work
with a slightly different scenario from the one in the examples
http://code.google.com/p/fluent-nhibernate/wiki/Examples, but are
having a problem trying to define the name of the foreighn key column
to be used when we perform a select query.

Our schema is as follows:

  table Customer (
    Id int primary key
    Name varchar(100),
    CustomerAddressId int        // Different from example
  )

  table CustomerAddress (
    CustomerAddressId int,       // Different from example
    Address varchar(100)
  )

The basic difference from the one in the examples is that our foreign
key is from Customer to CustomerAddress instead of the other way
around.

Our mapping looks like this:

    public CustomerMap()
        {
            Id(x => x.Id);
            Map(x => x.Name);
            WithTable("CustomerAddress", m =>
            {
                m.WithKeyColumn("CustomerAddressId"); // Different
from example
                m.Map(x => x.Address);
            });
        }

And the resulting SQL query is this:

  SELECT cust.Id, cust.Name, addr.Address
  FROM cg_temp..Customer cust inner join cg_temp..CustomerAddress
addr
     on cust.Id=addr.CustomerAddressId

.. the problem is that on the 3rd line 'cust.Id' should be
'cust.CustomerAddressId ' i.e.
   'on cust.CustomerAddressId =addr.CustomerAddressId'.

Any ideas on how I would do this?

--~--~---------~--~----~------------~-------~--~----~
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