views:

477

answers:

0

I am trying to join two tables to map to a single entity using NHibernate.Mapping.Attributes. It works when there is only one property in the joined table. However, when there are additional properties they get mapped to the primary table instead of the joined table.

[Class(Table = "primarytable")]
public class Entity
{
    [Id(0, Name = "Id")]
    [Generator(1, Class = "native")]
    public long Id
    { get; set; }

    [Property]
    public string Name
    { get; set; }

    // First property is mapped to joined table.

    [Join(0, Table = "joinedtable")]
    [Key(1, Column = "Id")]
    [Property(2)]
    public string Status
    { get; set; }

    // Adding another property gets mapped to primary table.

    [Property]
    public decimal AnotherProperty
    { get; set; }

How do you get additional properties to map to the joined table?