[英]C# Nhibernate mapping to lookup table
I'm having a difficult time mapping an entity to another entity that is a 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,
)
And Enitites: 和Enitite:
public class Candidate : Entity
{
public virtual Source Source { get; set; }
}
public class Source : Entity
{
public virtual string Name { get; set; }
}
I'm getting a error: 我收到一个错误:
An association from the table Candidates refers to an unmapped class: Entities.Source
表Candidates中的关联是指未映射的类:Entities.Source
But I am unsure how to go about the mapping: 但是我不确定如何进行映射:
public class CandidateMap : IAutoMappingOverride<Candidate>
{
public void Override(AutoMapping<Candidate> mapping)
{
mapping.Map(x => x.Source);
}
}
The problem was I was inheriting from the Entity that was part of NHibernate namespace, instead of the SharpArch.NHibernate namespace. 问题是我是从NHibernate命名空间而不是SharpArch.NHibernate命名空间继承的Entity继承的。 SharpArch does some mapping that the project I was working in was using.
SharpArch会做一些我正在使用的项目正在使用的映射。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.