我有这个对象:
class Person { Int32 id; String name; /*..*/ Adress adress; }
class Employee : Person { String e_g_Tax; /*..*/ Guid relationshipToManagmentId; }
And the follow premises for mapping:
(a) The "relationshipToManagmentId" should be a foreign key.
(b) The table "RelationshipToManagment" is a non-mapped table, (a old part of application)
(c) The mapping strategie is TPT. (at least for new objects :-)
绘图,直到现在:
public class PersonMap : ClassMap<Person> {
public PersonMap(){
Id(x => x.id);
Map (x => x.Nachname).Length(255).Not.Nullable();
/*..*/
References(x => x.Adresse).Class(typeof(Adresse)).Not.Nullable();
}
}
public class EmployeeMap : SubclassMap<Employee>
{
public EmployeeMap()
{
Map(x => x.e_g_Tax, "enjoytax")
.Not.Nullable();
/*..*/
Join("RelationshipToManagment", xJoin =>
{
//xJoin.Table("RelationshipToManagment");
xJoin.Fetch.Join();
xJoin.KeyColumn("ID");
xJoin.Map(x => x.relationshipToManagmentId)
.Not.Nullable() ;
}); // --> exception!!
我怎么能写这个?