This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// handy extension method to reduce a DateTime to the precision of a T-SQL DATETIME so that you can compare it with | |
// CLR DateTime's in unit tests | |
public static partial class ExtensionMethods | |
{ | |
public static DateTime ToSqlDateTimePrecision(this DateTime source) | |
{ | |
using (var ctx = new Data.DataContext()) | |
{ | |
return ctx.ExecuteQuery<DateTime>(string.Format("SELECT CONVERT(DATETIME, '{0}', 0)", source)).Single(); | |
} |