我有这样的实体
public class Person
{
public virtual int Pkey { get; set; }
public virtual string Name { get; set; }
public List<Person> Friends{ get; set; }
}
它的表信息是这样的
create table Person
(
PKey int not null IDENTITY,
Name varchar (20),
primary key (PKey)
)
要获取朋友列表,我正在维护另一个这样的表
Create table Friends
(
PKey int not null IDENTITY,
PersonFKey int not null Foreign key references Person(PKey),
FriendFKey int not null Foreign key references Person(PKey)
)
现在,当我进行如下映射时,我遇到了一些错误(由于映射问题)
public class PersonMap : ClassMap<Person>
{
public PersonMap()
{
Id(x => x.Pkey);
Map(x => x.Name);
HasManyToMany(x => x.Friends).Cascade.All().Table("Friends").ParentKeyColumn("PersonFKey");
}
}
抛出的异常是,
FluentConfigurationException: "An invalid or incomplete configuration was used while creating a SessionFactory. Check PotentialReasons collection, and InnerException for more detail."
除了内在的例外,
InvalidProxyTypeException: The following types may not be used as proxies:
FluentNhibernateLearning.Entities.Person: method get_Friends should be 'public/protected virtual' or 'protected internal virtual'
FluentNhibernateLearning.Entities.Person: method set_Friends should be 'public/protected virtual' or 'protected internal virtual'
谁能帮我指出我缺少的东西?