Fluent NHibernate AutoMapper 中的可访问性忽略属性映射
我有以下类,我正在使用 Fluent NHibernate 的 AutoMapper 进行映射。我不希望列表项可公开修改,因此有一个由 IList
支持的公共 IEnumerable
,它可以在内部填充或由 NHibernate 填充。
我希望 NHibernate 将 teamMembers
映射到名为 TeamMembers
的列。我还希望 FNH 忽略此类的 TeamMembers
属性。
public class Team : Entity
{
protected internal virtual IList<Person> teamMembers { get; set; }
public IEnumerable<Person> TeamMembers { get { return teamMembers;} }
}
I have the following class which I am mapping using Fluent NHibernate's AutoMapper. I do not want the list items publically modifiable so have a public IEnumerable
backed by an IList
which can be populated internally or by NHibernate.
I want NHibernate to map teamMembers
to a column named TeamMembers
. I also want FNH to ignore the TeamMembers
property on this class.
public class Team : Entity
{
protected internal virtual IList<Person> teamMembers { get; set; }
public IEnumerable<Person> TeamMembers { get { return teamMembers;} }
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
以下是告诉 NHibernate 的自动持久模型忽略您的属性的方法:
然后您就会得到您想要的东西。
Here's how you tell NHibernate's Autopersistence model to ignore your property:
You would then have just what you want.