Okay, so yesterday I managed to get the latest trunk builds of NHibernate and FluentNHibernate to work with my latest little project. (I\'m working on a bug tracking applica
You can use Auto Mapping Overrides to change how the Auto Mapper work, and you can also define Conventions, that will be used instead by the auto mapper.
Here is an example on how to use both the conventions and the overrides:
var mappings = new AutoPersistenceModel();
mappings.Conventions.Setup(s => s.Add());
mappings.UseOverridesFromAssemblyOf();
// This convention will set all properties to be not nullable
public class ColumnNullabilityConvention: IPropertyConvention, IPropertyConventionAcceptance
{
public void Accept(IAcceptanceCriteria criteria)
{
criteria.Expect(x => x.Nullable, Is.Not.Set);
}
public void Apply(IPropertyInstance instance)
{
instance.Not.Nullable();
}
}
// This override will change "string" to use "text" instead of "varchar(255)".
// Also set the property to be not nullable
public class SomeOverrideInTheSameAssembly : IAutoMappingOverride
{
public void Override(AutoMapping mapping)
{
mapping.Map(x => x.Property).CustomType("StringClob").CustomSqlType("text");
mapping.Map(x => x.Property).Not.Nullable();
}
}
Check these links for more examples: