1
考虑以下2类:流利映射问题-给予一定值到属性
public class TypeAGood{
public virtual int Id{get;set;}
public virtual string Description{get;set;}
public virtual Type Type{get;set;}
}
public virtual class Type{
public virtual int Id{get;set;}
public virtual string Name{get;set;}
}
映射:
public class TypeMap : ClassMap<Type>
{
public TypeMap()
{
Table("Type");
Id(x => x.Id);
Map(x => x.Name);
}
}
public class TypeAGoodMap : ClassMap<TypeAGood>
{
public TypeAGoodMap()
{
Table("Good");
Id(x => x.Id);
Map(x => x.Description);
References(x => x.Type)
.Fetch.Join()
.Column("TypeId")
.ForeignKey("Id");
}
}
类型可以有一个像,B,C不同的值。
如何更改TypeAGoodMap以仅映射具有Type a的商品?
感谢,
铝
克里斯感谢您reply.Your的解决方案似乎正是我need.Since这在fnh中不可用,你认为使用鉴别器/子类来解决这个问题是可能的吗? – Silvia 2010-02-08 22:14:48
根据您的域模型,这可能是可能的。是否有TypeBGood和TypeCGood?如果是这样,他们是否继承了IGood?在这种情况下,类型必须在数据库中具有良好(a,b或c),并且您可以在该列上区分是否有TypeAGood,TypeBGood等。 hbm解决方案有什么问题?我在映射中有很多混合项目,大约一半是流利的,一半是hbm。我喜欢流利的,但直到它可以匹配HBM中可用的东西,我不得不做这两件事,并没有那么糟糕。 – 2010-02-09 13:16:22