How to map NHibernate type to SQL Server TIME type? I use NH 3.2 and on the map.
public class Schedule { public virtual int Id { get; set; } public virtual string Name { get; set; } public virtual TimeSpan Time { get; set; } }
Here is my display class
public class ScheduleMapping : ClassMapping<Schedule> { public ScheduleMapping() { Id(x => x.Id, x => x.Generator(Generators.Native)); Property(x => x.Name, x => x.NotNullable(true)); Property(x => x.Time, x => x.NotNullable(true)); } }
Now, when I create a database from this column, "Time" is of type BIGINT SQL instead of TIME. I have read this and this article , but it is not clear to me how to apply any of these solutions.
============ EDIT =====================
I created and introduced a new schedule:
var newSchedule = new Schedule { Name = "My Schedule", Time = new TimeSpan(DateTime.Now.Hour, DateTime.Now.Minute, 0) }; session.SaveOrUpdate(newSchedule);
When this data was inserted (around 7:27 p.m.), the Time column contained a value of "700200000000", which could be ticks, but most importantly, when I requested DB for these values
var retrievedSchedules = session.QueryOver<Schedule>().List();
The Time property was correctly set to 19: 27. Initially, I wanted the Time property to represent the time at which the schedule should run. Despite the fact that the SQL Server data type for this column was defined as BIGINT, and the value is represented as (most likely) ticks, after extraction it was correctly translated at the time that I wanted. This is no longer a question, but I'm going to leave it, hopefully, to someone else.