Adding this convention will set the default length for string properties to 10000. As others have noted, this will be a nvarchar(max) column.
public class StringColumnLengthConvention : IPropertyConvention, IPropertyConventionAcceptance
{
public void Accept(IAcceptanceCriteria<IPropertyInspector> criteria)
{
criteria.Expect(x => x.Type == typeof(string)).Expect(x => x.Length == 0);
}
public void Apply(IPropertyInstance instance)
{
instance.Length(10000);
}
}
Conventions can be added to an automap configuration like this:
Fluently.Configure()
.Mappings( m =>
m.AutoMappings.Add( AutoMap.AssemblyOf<Foo>()
.Conventions.Add<StringColumnLengthConvention >()))
For more information, see Conventions in the Fluent NHibernate wiki.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…