Skip to content

Instantly share code, notes, and snippets.

View patsissons's full-sized avatar
🏗️
Always be building!

Pat Sissons patsissons

🏗️
Always be building!
View GitHub Profile
// 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();
}