更改 Fluent NHibernate Automapping 中连接类映射的列
我有一个继承
public abstract class UserEntity : Entity
{
public virtual int Id { get; protected set; }
}
public class Employee : UserEntity
{
public virtual string Email { get; set; }
}
Entity 是 NH 类的标准,其中重写方法 Equals、GetHashCode 等。我使用 AutMap 重写 .IncludeBase()
我使用 Fluent NHibernate Automapping 获得
<class xmlns="urn:nhibernate-mapping-2.2" name="Dto.Entities.UserEntity" table="UserEntities">
<id name="Id" type="System.Int32">
<column name="Id" />
<generator class="identity" />
</id>
<joined-subclass name="Dto.Entities.Employee" table="Employees">
<key foreign-key="FK_Employee_UserEntity">
<column name="UserEntityId" />
</key>
<property name="Email" type="System.String">
<column name="Email" />
</property>
</joined-subclass>
</class>
我想将连接子类中键列的名称从 UserEntityId 更改为 EmployeeId
我尝试
public class UserEntityOverride : IAutoMappingOverride<UserEntity>
{
public void Override(AutoMapping<UserEntity> mapping)
{
mapping.JoinedSubClass<Employee>("EmployeeId");
}
}
但没有成功。
我目前使用 NuGet 包中的最新 FNH:FluentNHibernate 1.2.0.712。 此外,我还有更多的配置和约定,这些配置和约定可能会以某种方式影响此配置忽略,但我已经尝试过一个明确的解决方案,但得到了相同的负面结果。
I have an inheritance
public abstract class UserEntity : Entity
{
public virtual int Id { get; protected set; }
}
public class Employee : UserEntity
{
public virtual string Email { get; set; }
}
Entity is a standard for NH class where overridden methods Equals, GetHashCode, etc. And I use AutMap rewriting .IncludeBase()
I got with Fluent NHibernate Automapping
<class xmlns="urn:nhibernate-mapping-2.2" name="Dto.Entities.UserEntity" table="UserEntities">
<id name="Id" type="System.Int32">
<column name="Id" />
<generator class="identity" />
</id>
<joined-subclass name="Dto.Entities.Employee" table="Employees">
<key foreign-key="FK_Employee_UserEntity">
<column name="UserEntityId" />
</key>
<property name="Email" type="System.String">
<column name="Email" />
</property>
</joined-subclass>
</class>
I want to change name for key column in joined subclass from UserEntityId to EmployeeId
I try
public class UserEntityOverride : IAutoMappingOverride<UserEntity>
{
public void Override(AutoMapping<UserEntity> mapping)
{
mapping.JoinedSubClass<Employee>("EmployeeId");
}
}
but didn't have success.
I use the latest for this moment FNH from NuGet package: FluentNHibernate 1.2.0.712.
Also I have much more configuration and conventions that can somehow affect on this configuration ignoring, but I have tried it on a clear solution with the same negative result.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论