Fluent NHibernate - 自动映射:单个属性允许为 null
我知道这个问题已经以类似的形式多次提出,但没有一个线程可以给我问题的具体答案。
我使用 Fluent NHibernate 和 Fluent 的自动映射来映射我的域实体。现在,我使用这个约定类来设置所有属性NOT NULL:
public class NotNullColumnConvention : IPropertyConvention
{
public void Apply(FluentNHibernate.Conventions.Instances.IPropertyInstance instance)
{
instance.Not.Nullable();
}
}
最大的问题是:
我需要做什么,以允许实体类的单个属性为NULL强>?
这是我的实体类之一:
public class Employee : Entity
{
public virtual string FirstName { get; set; }
public virtual string LastName { get; set; }
}
如果有人最终能帮助我,我会非常高兴!我已输入 Google 返回页面的所有可能的搜索字符串,标记为已访问...
谢谢,
Arne
编辑:更改了标题...想要允许单个属性 NULL
I know this question has been raised in similar form multiple times, but none of the threads could give me the concrete answer to my question.
I use Fluent NHibernate and Fluent`s auto-mapping to map my domain entities. Right now, I use this convention class to set all properties NOT NULL:
public class NotNullColumnConvention : IPropertyConvention
{
public void Apply(FluentNHibernate.Conventions.Instances.IPropertyInstance instance)
{
instance.Not.Nullable();
}
}
The big question is:
What do I need to do, to allow single properties of my entity classes to be NULL?
Here is one of my entity classes:
public class Employee : Entity
{
public virtual string FirstName { get; set; }
public virtual string LastName { get; set; }
}
I´d be really pleased, if someone can finally help me out! All possible search string I have entered into Google return pages, marked as already visited...
Thanks,
Arne
EDIT: Changed title ... Want to allow NULL for single properties
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
创建一个属性:
和一个约定:
将属性放在属性之上。
Create an attribute :
And a convention :
Drop the attribute on top of your properties.