问题描述
我最近升级的 FluentNHibernate 从 v1.1.0.685 为 v1.2.0.712 (最新的),对于 NHibernate的2.1
I recently upgraded FluentNHibernate from v1.1.0.685 to v1.2.0.712 (latest) for NHibernate 2.1.
看来我的问题是与使用组件()。列preFIX()
映射类。
My issue appears to be with classes that use the Component().ColumnPrefix()
mapping.
例如,
public class Address{
public string Street {get; set;}
public string Zip {get; set;}
}
public class AddressMap : ComponentMap<Address>{
Map( x => x.Street );
Map( x => x.Zip );
}
public class PersonMap : ClassMap<Person>
{
public PersonMap(){
Id( x => x.Id );
Map( x=> x.Name );
Component( x => x.Address )
.ColumnPrefix("ADDRESS_");
}
}
人员表的
Id Name ADDRESS_Street ADDRESS_Zip
----------------------------------------------------
1 Brian 123 Example St. 12345
在FNH v1.1.0.685行为
在ADDRESS _ preFIX是的正确的应用于地址组件的属性。
Behavior in FNH v1.1.0.685
The "ADDRESS_" prefix is correctly applied to the properties of the Address component.
在ADDRESS _ preFIX是的不再的应用于地址组件的属性。 NHiberante 生成街道和邮编未在表中指定的列。
The "ADDRESS_" prefix is no longer applied to the properties of the Address component. NHiberante generates "Street" and "Zip" columns which are not named in table above.
我倒是AP preciate如果任何人有任何见解。我开始觉得这的也许的是一个错误。
I'd appreciate if anyone has any insight. I'm beginning to think this might be a bug.
谢谢,
布莱恩
Thanks,
Brian
推荐答案
调查源$ C $ C单元测试后,看来,在我的情况,我的公约,正在之间施加不同的 FNH V1.1 和 FNH V1.2
After investigating the unit tests in the source code; it appears that, in my case, my conventions were being applied differently between FNH v1.1 and FNH v1.2.
我觉得这是发生了什么:
I think this is what happened:
-
我的
AddressMap:ComponentMap&LT;地址&gt;
将得到执行(这里没问题)
My
AddressMap : ComponentMap<Address>
would get executed (no problem here).
我的 PersonMap:ClassMap&LT;人&GT;
将使用地图的组件:
My PersonMap : ClassMap<Person>
would map a component using:
Component( x => x.Address ).ColumnPrefix("ADDRESS_");
从第1步。
我的 FNH MyPropertyConvention
将要求:
public class MyPropertyConvention : IPropertyConvention
{
public void Apply( IPropertyInstance instance )
{
instance.Column( instance.Name ); //this call is destructive
//to ColumnPrefix() in FNH v1.2
}
}
看来:
-
在 FNH V1.1 ,第3步的不是破坏性的调用时,列preFIX
instance.Column( )
。
in FNH v1.1, Step 3 is not destructive to the column prefix when calling
instance.Column()
.
在 FNH V1.2 ,第3步的破坏的任何列preFIX()
previously设置和过度写的全部的列名(包括preFIX)。
in FNH v1.2, Step 3 is destructive to any ColumnPrefix()
previously set and over-writes the entire column name (including the prefix).
所以,我清理了我的约定 FNH 1.2 使用 IPropertyConventionAcceptance
并注意我的呼叫 instance.Column (instance.Name)
[现在的呼叫会破坏列prefixes。
So, I cleaned up my conventions for FNH 1.2 using IPropertyConventionAcceptance
being careful about my calls to instance.Column(instance.Name)
[now that calls are destructive to column prefixes].
感谢大家的帮助,
布莱恩
Thanks for everyone's help,
Brian
这篇关于FluentNHibernate Component.Column preFIX没有被应用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!