[英]C# Nhibernate mapping to lookup table
我在将一个实体映射到另一个作为查找表的实体时遇到了困难。
create table Sources
(
SourceId identity(1,1) primary key not null,
Name [nvarchar](255) NULL,
)
create table Candidates
(
CandidateId int identity(1,1) primary key not null,
SourceId int references Sources(SourceId) NULL,
)
和Enitite:
public class Candidate : Entity
{
public virtual Source Source { get; set; }
}
public class Source : Entity
{
public virtual string Name { get; set; }
}
我收到一个错误:
表Candidates中的关联是指未映射的类:Entities.Source
但是我不确定如何进行映射:
public class CandidateMap : IAutoMappingOverride<Candidate>
{
public void Override(AutoMapping<Candidate> mapping)
{
mapping.Map(x => x.Source);
}
}
问题是我是从NHibernate命名空间而不是SharpArch.NHibernate命名空间继承的Entity继承的。 SharpArch会做一些我正在使用的项目正在使用的映射。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.