How to set db column name for orchard record column?

Topics: Writing modules
Jun 13, 2012 at 3:11 PM
Edited Jun 13, 2012 at 3:12 PM

I have existing table in my orchard and I want to map this table to Orchard as Record.

This table has different naming convention. Can I set db column name for it?

Some thing like:

public class GeonamesRecord
{       
    public virtual long Id { get; set; }
}
SchemaBuilder.CreateTable("GeonamesRecord", table => table
    .Column<long>("Id", x => x.PrimaryKey().NotNull().DbColumnName("geonamesid"))
Jun 20, 2012 at 8:40 PM
Edited Jun 30, 2012 at 9:48 PM

It is possible to get access to Fluent NHibernate mapping configuration:

    public class DbColumnNameAttribute : Attribute
    {
        public string DbColumnName { get; protected set; }

        public DbColumnNameAttribute(string dbColumnName)
        {
            DbColumnName = dbColumnName;
        }
    }

    public class ColumnNameMappingConvention : AttributePropertyConvention<DbColumnNameAttribute>
    {
        protected override void Apply(DbColumnNameAttribute attribute, IPropertyInstance instance)
        {
            instance.Column(attribute.DbColumnName);
        }
    }