Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Equivalent of time(7) SQL Server 2008 datatype in .NET

What is the equivalent of SQL Server 2008's time(7) datatype in .NET? I want to store hours and minutes alone in that column, for this which datatype should I use in SQL Server!

like image 975
banupriya Avatar asked Jan 19 '23 15:01

banupriya


1 Answers

MSDN gives a mapping between SQL data types and CLR data types - and it suggests TimeSpan and Nullable<TimeSpan> (for nullable columns) too. Note that how you access the data will determine how you actually get the value out though. DbDataReader doesn't have a GetTimeSpan method for example - but SqlDataReader does have such a method. I'd expect LINQ to SQL or Entity Framework to perform the mapping automatically.

like image 175
Jon Skeet Avatar answered Jan 27 '23 04:01

Jon Skeet