Gui*_*ion 9 nhibernate nhibernate-mapping fluent-nhibernate sql-server-2008
我的SQL Server 2008数据库中有一个包含时间列的表.
我想要映射到的对象的属性是TimeSpan.
我如何告诉FluentNHibernate使用TimeAsTimeSpan NHibernate类型,以便我没有演员问题?
这对我有用:
Map(x => x.TimeFrom)
.CustomType("TimeAsTimeSpan");
Run Code Online (Sandbox Code Playgroud)
如果你正在使用这些约定,那么这对我有用:
public class PropertyConvention : IPropertyConvention
{
public void Apply(IPropertyInstance instance)
{
if (instance.Property.PropertyType == typeof(TimeSpan))
instance.CustomType( "TimeAsTimeSpan" );
}
}
Run Code Online (Sandbox Code Playgroud)