开发者

Sharp Architecture ignoring my Formula mappings

I'm having a problem where Sharp Architecture will correctly map everything I have setup in my IAutoMappingOverride classes, except for Formula. These get simply ignored and thus I get SQL's invalid identifier when trying to query the database.

// NUnit setup
public virtual void SetUp()
{
    configuration = NHibernateSession.Init(
        new SimpleSessionStorage(),
        RepositoryTestsHelper.GetMappingAssemblies(),
        new AutoPersistenceModelGenerator().Generate(),
        null,
        null,
        null,
        FluentConfigurer.TestConfigurer.Contracts);

    new FluentConfigurer(configuration)
        .ConfigureNHibernateValidator()
        .ConfigureAuditListeners();
}


public AutoPersistenceModel Generate()
{
    return AutoMap.AssemblyOf<Contrato>(new AutomappingConfiguration())
        .Conventions.Setup(GetConventions())
        .IgnoreBase<Entity>()
        .IgnoreBase(typeof(EntityWithTypedId<>))
        .UseOverridesFromAssemblyOf<EmployeeMap>();
}

// My override.
public class EmployeeMap : IAutoMappingOverride<Employee>
{
    public void Override(AutoMapping<Employee> mapping)
    {
        // This works...
        mapping.Id(x => x.Id, "ID_EMPLOYEE");

        // This is ignored...
        mapping.Map(x => x.Name).Formula("UPPER(LTRIM(RTRIM(FIRST_NAME || ' 开发者_StackOverflow' || LAST_NAME)))");
    }
}

Any ideas?


This is not an issue with Sharp Architecture, it is an issue with Fluent Nhibernate. What version of FNH are you using?


I confirmed this is an issue with Fluent NHibernate (1.2.0.694). Previously, a column-name mapping would give precedence to the FluentMappingOverrides, but the latest would give precedence to the Convention. I modified my convention to exclude the namespaces that contain the formula mappings and now it's Ok.

    public class OracleUnderscoredNamingConvention : IPropertyConvention 
    { 
        public void Apply(IPropertyInstance instance) 
        { 
            // Previously worked without this condition. 
            if 
(Utils.WorkableDomainNamespaces.Contains(instance.Property.PropertyType.Nam espace)) 
            { 
instance.Column(OracleConventionSetter.ApplyOracleNamingConventions(instanc e.Property.Name)); 
            } 
        } 
    } 
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜