Castle ActiveRecord - can I use the SQL Server 2008 "time" data type?
I'm working on a project where I need to track times, such as "2:开发者_如何转开发15 PM" without dates. I'm using Castle ActiveRecord. Is there a way I can specify using the Castle attributes that I want my field to be a time data type in SQL Server 2008? And if so, what .NET type would I make the field? DateTime?
In addition, I may need to attach time zones to these times. What's the best way to do this using Castle ActiveRecord and SQL Server 2008?
According to the MSDN docs the time datatype corresponds to a TimeSpan .net type, and the NHibernate type is "TimeAsTimeSpan". In ActiveRecord you'd use the ColumnType property to define this, see this example.
If you want to include time zones I recommend using DateTimeOffset instead. I don't see how time zones would make sense in a TimeSpan... Or store the timezone in a separate field and do the conversions yourself...
精彩评论