Nhibernate 3 Specify Sql Data Type With Loquacious Syntax
I'm trying to map an Entity with a string property to a varchar column in NHibernate 3 using the new Loquacious API but I can't figure out how to specify the Type to use. I am abl
Solution 1:
ca.Property(x => x.Code, map =>
{
map.Type(NHibernateUtil.AnsiString);
map.Column(/*etc.*/);
});
Solution 2:
An answer to the question itself ("specify sql type") would be to define the property like this:
ca.Property(x => x.Code, map =>
{
map.Column(cm => {
cm.Name("EnityCode");
cm.NotNullable(true);
cm.SqlType("varchar");
});
});
Directly specifying the SQL type should be considered a hack which is not necessary here, though. It's preferable to use the map.Type(NHibernateUtil.AnsiString); solution and have NHibernate deduce the SQL type.
Post a Comment for "Nhibernate 3 Specify Sql Data Type With Loquacious Syntax"