Skip to content

Commit

Permalink
Built out expression translators for DateDiff implementations in SQL
Browse files Browse the repository at this point in the history
  • Loading branch information
Whit Waldo committed Mar 5, 2019
1 parent 8c3598e commit fafeb9c
Show file tree
Hide file tree
Showing 2 changed files with 324 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,18 @@ private readonly Dictionary<MethodInfo, string> _methodInfoDateDiffMapping
new[] { typeof(DbFunctions), typeof(DateTimeOffset?), typeof(DateTimeOffset?) }),
"DAY"
},
{
typeof(SqlServerDbFunctionsExtensions).GetRuntimeMethod(
nameof(SqlServerDbFunctionsExtensions.DateDiffDay),
new[] { typeof(DbFunctions), typeof(TimeSpan), typeof(TimeSpan) }),
"DAY"
},
{
typeof(SqlServerDbFunctionsExtensions).GetRuntimeMethod(
nameof(SqlServerDbFunctionsExtensions.DateDiffDay),
new[] { typeof(DbFunctions), typeof(TimeSpan?), typeof(TimeSpan?) }),
"DAY"
},
{
typeof(SqlServerDbFunctionsExtensions).GetRuntimeMethod(
nameof(SqlServerDbFunctionsExtensions.DateDiffHour),
Expand All @@ -117,6 +129,18 @@ private readonly Dictionary<MethodInfo, string> _methodInfoDateDiffMapping
new[] { typeof(DbFunctions), typeof(DateTimeOffset?), typeof(DateTimeOffset?) }),
"HOUR"
},
{
typeof(SqlServerDbFunctionsExtensions).GetRuntimeMethod(
nameof(SqlServerDbFunctionsExtensions.DateDiffHour),
new[] { typeof(DbFunctions), typeof(TimeSpan), typeof(TimeSpan) }),
"HOUR"
},
{
typeof(SqlServerDbFunctionsExtensions).GetRuntimeMethod(
nameof(SqlServerDbFunctionsExtensions.DateDiffHour),
new[] { typeof(DbFunctions), typeof(TimeSpan?), typeof(TimeSpan?) }),
"HOUR"
},
{
typeof(SqlServerDbFunctionsExtensions).GetRuntimeMethod(
nameof(SqlServerDbFunctionsExtensions.DateDiffMinute),
Expand All @@ -141,6 +165,18 @@ private readonly Dictionary<MethodInfo, string> _methodInfoDateDiffMapping
new[] { typeof(DbFunctions), typeof(DateTimeOffset?), typeof(DateTimeOffset?) }),
"MINUTE"
},
{
typeof(SqlServerDbFunctionsExtensions).GetRuntimeMethod(
nameof(SqlServerDbFunctionsExtensions.DateDiffMinute),
new[] { typeof(DbFunctions), typeof(TimeSpan), typeof(TimeSpan) }),
"MINUTE"
},
{
typeof(SqlServerDbFunctionsExtensions).GetRuntimeMethod(
nameof(SqlServerDbFunctionsExtensions.DateDiffMinute),
new[] { typeof(DbFunctions), typeof(TimeSpan?), typeof(TimeSpan?) }),
"MINUTE"
},
{
typeof(SqlServerDbFunctionsExtensions).GetRuntimeMethod(
nameof(SqlServerDbFunctionsExtensions.DateDiffSecond),
Expand All @@ -165,6 +201,18 @@ private readonly Dictionary<MethodInfo, string> _methodInfoDateDiffMapping
new[] { typeof(DbFunctions), typeof(DateTimeOffset?), typeof(DateTimeOffset?) }),
"SECOND"
},
{
typeof(SqlServerDbFunctionsExtensions).GetRuntimeMethod(
nameof(SqlServerDbFunctionsExtensions.DateDiffSecond),
new[] { typeof(DbFunctions), typeof(TimeSpan), typeof(TimeSpan) }),
"SECOND"
},
{
typeof(SqlServerDbFunctionsExtensions).GetRuntimeMethod(
nameof(SqlServerDbFunctionsExtensions.DateDiffSecond),
new[] { typeof(DbFunctions), typeof(TimeSpan?), typeof(TimeSpan?) }),
"SECOND"
},
{
typeof(SqlServerDbFunctionsExtensions).GetRuntimeMethod(
nameof(SqlServerDbFunctionsExtensions.DateDiffMillisecond),
Expand All @@ -189,6 +237,18 @@ private readonly Dictionary<MethodInfo, string> _methodInfoDateDiffMapping
new[] { typeof(DbFunctions), typeof(DateTimeOffset?), typeof(DateTimeOffset?) }),
"MILLISECOND"
},
{
typeof(SqlServerDbFunctionsExtensions).GetRuntimeMethod(
nameof(SqlServerDbFunctionsExtensions.DateDiffMillisecond),
new[] { typeof(DbFunctions), typeof(TimeSpan), typeof(TimeSpan) }),
"MILLISECOND"
},
{
typeof(SqlServerDbFunctionsExtensions).GetRuntimeMethod(
nameof(SqlServerDbFunctionsExtensions.DateDiffMillisecond),
new[] { typeof(DbFunctions), typeof(TimeSpan?), typeof(TimeSpan?) }),
"MILLISECOND"
},
{
typeof(SqlServerDbFunctionsExtensions).GetRuntimeMethod(
nameof(SqlServerDbFunctionsExtensions.DateDiffMicrosecond),
Expand All @@ -213,6 +273,18 @@ private readonly Dictionary<MethodInfo, string> _methodInfoDateDiffMapping
new[] { typeof(DbFunctions), typeof(DateTimeOffset?), typeof(DateTimeOffset?) }),
"MICROSECOND"
},
{
typeof(SqlServerDbFunctionsExtensions).GetRuntimeMethod(
nameof(SqlServerDbFunctionsExtensions.DateDiffMicrosecond),
new[] { typeof(DbFunctions), typeof(TimeSpan), typeof(TimeSpan) }),
"MICROSECOND"
},
{
typeof(SqlServerDbFunctionsExtensions).GetRuntimeMethod(
nameof(SqlServerDbFunctionsExtensions.DateDiffMicrosecond),
new[] { typeof(DbFunctions), typeof(TimeSpan?), typeof(TimeSpan?) }),
"MICROSECOND"
},
{
typeof(SqlServerDbFunctionsExtensions).GetRuntimeMethod(
nameof(SqlServerDbFunctionsExtensions.DateDiffNanosecond),
Expand All @@ -236,6 +308,18 @@ private readonly Dictionary<MethodInfo, string> _methodInfoDateDiffMapping
nameof(SqlServerDbFunctionsExtensions.DateDiffNanosecond),
new[] { typeof(DbFunctions), typeof(DateTimeOffset?), typeof(DateTimeOffset?) }),
"NANOSECOND"
},
{
typeof(SqlServerDbFunctionsExtensions).GetRuntimeMethod(
nameof(SqlServerDbFunctionsExtensions.DateDiffNanosecond),
new[] { typeof(DbFunctions), typeof(TimeSpan), typeof(TimeSpan) }),
"NANOSECOND"
},
{
typeof(SqlServerDbFunctionsExtensions).GetRuntimeMethod(
nameof(SqlServerDbFunctionsExtensions.DateDiffNanosecond),
new[] { typeof(DbFunctions), typeof(TimeSpan?), typeof(TimeSpan?) }),
"NANOSECOND"
}
};

Expand Down
Loading

0 comments on commit fafeb9c

Please sign in to comment.