i have this 2 class
public class Product {
public virtual Guid Id {get; set;}
public virtual string Name {get; set;}
public virtual Description Description {get; set;}
}
public class Description {
public virtual Guid Id {get; set;}
public virtual string Suggestion {get; set;}
public virtual string Composition {get; set;}
}
i've try to map the class with this Mapper class:
public class ProductMap : ClassMap<Product>
{
public ProductMap()
{
Id(x => x.Id);
Map(x => x.Name);
References(x => x.Description).ForeignKey("Id");
}
}
Description was related to Product with same Id, so e.g Product with Id = 1 will have description in table with Id = 1. Now i try to read data from the table with this:
using (var session = factory.OpenSession())
{
var testProduct = session.Query<Product>().Where(p => p.Id == 2).Single();
lblValue.Text = testProduct.Description.Composition;
}
but i get error exception
InnerException: System.Data.SqlClient.SqlException
Message=Invalid column name 'Description_id'.
i know i've put something wrong in mapper constructor. Could u guys help me how to map this correctly. i dont want to put field Description_id in table Product. Thanks