I run this sample here: https://github.com/jagregory/fluent-nhibernate/blob/master/src/Examples.FirstProject/Program.cs
All C# Properties of type String are mapped into TEXT sql fields and not
nvarchar OR varchar as I would except it to be as DEFAULT setting.
How can I change that?
I know I can do this:
Map(x => x.Name).CustomSqlType("nvarchar").Length(50); // does not work !!!
Map(x => x.Name).CustomSqlType("nvarchar (50)"); // does work !!!
but I do not want to change every field...
UPDATE: ... therefore I can do a custom convention via =>
What I have to do is write a custom Convention class like:
public class ColumnStringToNVarCharConvention : IPropertyConvention, IPropertyConventionAcceptance
{
public void Apply(IPropertyInstance instance)
{
instance.CustomSqlType("nvarchar");
}
public void Accept(IAcceptanceCriteria<IPropertyInspector> criteria)
{
criteria.Expect(x => x.Property.GetType().Equals(typeof(string)));
}
}
Can someone proper the above code? I tested it and it did not work whyever...