Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/asp.net-mvc/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Fluent nhibernate ICompositeUserType的列名是否可以在FluentNHibernate约定中进行控制?_Fluent Nhibernate - Fatal编程技术网

Fluent nhibernate ICompositeUserType的列名是否可以在FluentNHibernate约定中进行控制?

Fluent nhibernate ICompositeUserType的列名是否可以在FluentNHibernate约定中进行控制?,fluent-nhibernate,Fluent Nhibernate,我创建了一个IUserTypeConvention约定,在匹配类型的所有属性上使用ICompositeUserType实现: public abstract class CompositeUserTypeConvention<TUserType> : IUserTypeConvention where TUserType : ICompositeUserType, new() { public virtual void Accept(IAcceptanceC

我创建了一个
IUserTypeConvention
约定,在匹配类型的所有属性上使用
ICompositeUserType
实现:

public abstract class CompositeUserTypeConvention<TUserType> 
    : IUserTypeConvention
    where TUserType : ICompositeUserType, new()
{
    public virtual void Accept(IAcceptanceCriteria<IPropertyInspector> criteria)
    {
        var userType = new TUserType();

        criteria.Expect(x => x.Type == userType.ReturnedClass);
    }

    public virtual void Apply(IPropertyInstance instance)
    {
        instance.CustomType<TUserType>();
    }
}
公共抽象类CompositeUserTypeConvention
:IUserTypeConvention
其中TUserType:ICompositeUserType,new()
{
公共虚拟无效接受(IAcceptanceCriteria标准)
{
var userType=new TUserType();
Expect(x=>x.Type==userType.ReturnedClass);
}
公共虚拟无效应用(IPropertyInstance实例)
{
CustomType();
}
}
应用此方法时,FluentNHibernate使用
{memberpropertyname}{compositepropertyname}
的约定为复合类型的每个属性生成列名

对于属性为
Amount
Currency
的组合类型如
Money
,如果我的实体上有一个名为
Price
Money
类型的属性,则预期的列称为
Price\u Currency
Price\u Amount

我想更改此约定以删除下划线,但我不知道如何或是否可能。
CustomType()
方法有一个重载,该重载接受
columnPrefix
作为参数。默认行为是将属性名+“389;”作为此值传递。明确指定该值会得到所需的结果:

public virtual void Apply(IPropertyInstance instance)
{
    instance.CustomType<TUserType>(instance.Name);
}
公共虚拟无效应用(IPropertyInstance实例)
{
instance.CustomType(instance.Name);
}
方法的
CustomType()
有一个重载,它接受
列前缀作为参数。默认行为是将属性名+“389;”作为此值传递。明确指定该值会得到所需的结果:

public virtual void Apply(IPropertyInstance instance)
{
    instance.CustomType<TUserType>(instance.Name);
}
公共虚拟无效应用(IPropertyInstance实例)
{
instance.CustomType(instance.Name);
}

在FluentNHibernate的当前版本中,此重载似乎已被删除。有关当前最新的答案,请参阅。在FluentNHibernate的当前版本中,此重载似乎已被删除。有关当前最新的答案,请参阅。