views:

20

answers:

1

I'm having some problems with getting the following convention to work:

public class ColumnNameUpperConvention : IPropertyConvention
{
    public void Apply(IPropertyInstance instance)
    {          
        string cName = instance.Property.Name.ToUpper();
        instance.Column(cName);
    }
}

What I'm wanting the above code to do is to map a property called "Modified" to a column named "MODIFIED".

And this is my config:

var config =
    Fluently.Configure()
        .Database(OracleClientConfiguration.Oracle10
        .ConnectionString(c => c.FromConnectionStringWithKey(cstringName)))
        .Mappings(m =>
            {
                m.FluentMappings.AddFromAssemblyOf<AgilityObject>();
                m.AutoMappings.Add(
                        AutoMap.AssemblyOf<AgilityObject>(mappingConfiguration)
                       .Conventions.Add<ColumnNameUpperConvention>());
            })
        .ExposeConfiguration(x => x.SetProperty("current_session_context_class", "thread_static"))
        .ExposeConfiguration(x => x.SetProperty("generate_statistics", "true"))
        .BuildSessionFactory();

When I debug I can see that my convention code gets executed, but it doesn't seem like it actually does anything.

Am I missing something?

PS. Do the mappings I've set explicitly in a ClassMap automatically override conventions? There are exceptions to the above convention and I want to map those properties by hand.

A: 

My bad. I needed to use IAutoMappingOverride instead of ClassMap if I am to use AutoMapping at all.

Ciddan