Using Time columns with NHibernate, Fluent NHibernate and SQL Server 2008

后端 未结 3 1852
别那么骄傲
别那么骄傲 2021-01-04 20:15

I have a table with a time column in my SQL Server 2008 database.

The property of the object I\'m trying to map to is a TimeSpan.

How can i tell FluentNHiber

相关标签:
3条回答
  • 2021-01-04 20:24

    You should be able to map it using CustomType.

    0 讨论(0)
  • 2021-01-04 20:35

    And if you're using the conventions, then this does the job for me:

    public class PropertyConvention : IPropertyConvention 
    {
        public void Apply(IPropertyInstance instance)
        {
            if (instance.Property.PropertyType == typeof(TimeSpan))
                instance.CustomType( "TimeAsTimeSpan" );
        }
    }
    
    0 讨论(0)
  • 2021-01-04 20:39

    This is working for me:

    Map(x => x.TimeFrom)
        .CustomType("TimeAsTimeSpan");
    
    0 讨论(0)
提交回复
热议问题