如何使我的属性约定忽略具有公式的映射?
有人可以告诉我如何使我的属性约定忽略具有公式的映射吗?
这是实体:
public class User
{
public virtual int Id {get; set;}
public virtual string FirstName {get; set;}
public virtual string LastName {get; set;}
public virtual string FullName {get; set;}
}
这是映射:
public class UserMap : ClassMap<User>
{
public UserMap()
{
Id(x => x.Id);
Map(x => x.FirstName);
Map(x => x.LastName);
Map(x => x.FullName).Formula("first_name || ' ' || last_name");
}
}
我希望我的属性约定忽略 FullName 属性。 感谢您的帮助
Can someone tell me how to make my property convention ignore a mapping that has formula?
This is the entity:
public class User
{
public virtual int Id {get; set;}
public virtual string FirstName {get; set;}
public virtual string LastName {get; set;}
public virtual string FullName {get; set;}
}
This is the mapping:
public class UserMap : ClassMap<User>
{
public UserMap()
{
Id(x => x.Id);
Map(x => x.FirstName);
Map(x => x.LastName);
Map(x => x.FullName).Formula("first_name || ' ' || last_name");
}
}
I want my property convention to ignore the FullName property.
Thanks for helping
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的约定是否实施 IConventionAcceptance(或等效的 IPropertyConventionAcceptance)?从那里,在 Accept 方法中,您可以访问“Formula”属性并相应地返回 true/false。这将阻止您的约定处理该属性。
Is your convention implementing IConventionAcceptance (or the equivalent IPropertyConventionAcceptance)? From there, within the Accept method, you can access the "Formula" property and return true/false appropriately. This will prevent your convention from processing the property.