Skip to content

Commit

Permalink
Updated to attempt to convert the target object to a datetime before …
Browse files Browse the repository at this point in the history
…applying a datetime function. Issue beyond-code-github#53.
  • Loading branch information
ccoulson committed Mar 5, 2015
1 parent 5fd8378 commit a117457
Show file tree
Hide file tree
Showing 11 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion LinqToQuerystring/TreeNodes/Functions/DayNode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public override Expression BuildLinqExpression(IQueryable query, Expression expr

if (!typeof(DateTime).IsAssignableFrom(childexpression.Type) && !typeof(DateTimeOffset).IsAssignableFrom(childexpression.Type))
{
throw new FunctionNotSupportedException(childexpression.Type, "day");
childexpression = Expression.Convert(childexpression, typeof(DateTime));
}

return Expression.Property(childexpression, "Day");
Expand Down
2 changes: 1 addition & 1 deletion LinqToQuerystring/TreeNodes/Functions/DaysNode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public override Expression BuildLinqExpression(IQueryable query, Expression expr

if (!typeof(DateTime).IsAssignableFrom(childexpression.Type))
{
throw new FunctionNotSupportedException(childexpression.Type, "days");
childexpression = Expression.Convert(childexpression, typeof(DateTime));
}

return Expression.Property(childexpression, "Day");
Expand Down
2 changes: 1 addition & 1 deletion LinqToQuerystring/TreeNodes/Functions/HourNode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public override Expression BuildLinqExpression(IQueryable query, Expression expr

if (!typeof(DateTime).IsAssignableFrom(childexpression.Type) && !typeof(DateTimeOffset).IsAssignableFrom(childexpression.Type))
{
throw new FunctionNotSupportedException(childexpression.Type, "hour");
childexpression = Expression.Convert(childexpression, typeof(DateTime));
}

return Expression.Property(childexpression, "Hour");
Expand Down
2 changes: 1 addition & 1 deletion LinqToQuerystring/TreeNodes/Functions/HoursNode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public override Expression BuildLinqExpression(IQueryable query, Expression expr

if (!typeof(DateTime).IsAssignableFrom(childexpression.Type))
{
throw new FunctionNotSupportedException(childexpression.Type, "hours");
childexpression = Expression.Convert(childexpression, typeof(DateTime));
}

return Expression.Property(childexpression, "Hour");
Expand Down
2 changes: 1 addition & 1 deletion LinqToQuerystring/TreeNodes/Functions/MinuteNode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public override Expression BuildLinqExpression(IQueryable query, Expression expr

if (!typeof(DateTime).IsAssignableFrom(childexpression.Type) && !typeof(DateTimeOffset).IsAssignableFrom(childexpression.Type))
{
throw new FunctionNotSupportedException(childexpression.Type, "minute");
childexpression = Expression.Convert(childexpression, typeof(DateTime));
}

return Expression.Property(childexpression, "Minute");
Expand Down
2 changes: 1 addition & 1 deletion LinqToQuerystring/TreeNodes/Functions/MinutesNode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public override Expression BuildLinqExpression(IQueryable query, Expression expr

if (!typeof(DateTime).IsAssignableFrom(childexpression.Type))
{
throw new FunctionNotSupportedException(childexpression.Type, "minutes");
childexpression = Expression.Convert(childexpression, typeof(DateTime));
}

return Expression.Property(childexpression, "Minute");
Expand Down
2 changes: 1 addition & 1 deletion LinqToQuerystring/TreeNodes/Functions/MonthNode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public override Expression BuildLinqExpression(IQueryable query, Expression expr

if (!typeof(DateTime).IsAssignableFrom(childexpression.Type))
{
throw new FunctionNotSupportedException(childexpression.Type, "month");
childexpression = Expression.Convert(childexpression, typeof(DateTime));
}

return Expression.Property(childexpression, "Month");
Expand Down
2 changes: 1 addition & 1 deletion LinqToQuerystring/TreeNodes/Functions/SecondNode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public override Expression BuildLinqExpression(IQueryable query, Expression expr

if (!typeof(DateTime).IsAssignableFrom(childexpression.Type) && !typeof(DateTimeOffset).IsAssignableFrom(childexpression.Type))
{
throw new FunctionNotSupportedException(childexpression.Type, "second");
childexpression = Expression.Convert(childexpression, typeof(DateTime));
}

return Expression.Property(childexpression, "Second");
Expand Down
2 changes: 1 addition & 1 deletion LinqToQuerystring/TreeNodes/Functions/SecondsNode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public override Expression BuildLinqExpression(IQueryable query, Expression expr

if (!typeof(DateTime).IsAssignableFrom(childexpression.Type))
{
throw new FunctionNotSupportedException(childexpression.Type, "seconds");
childexpression = Expression.Convert(childexpression, typeof(DateTime));
}

return Expression.Property(childexpression, "Second");
Expand Down
2 changes: 1 addition & 1 deletion LinqToQuerystring/TreeNodes/Functions/YearNode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public override Expression BuildLinqExpression(IQueryable query, Expression expr

if (!typeof(DateTime).IsAssignableFrom(childexpression.Type) && !typeof(DateTimeOffset).IsAssignableFrom(childexpression.Type))
{
throw new FunctionNotSupportedException(childexpression.Type, "year");
childexpression = Expression.Convert(childexpression, typeof(DateTime));
}

return Expression.Property(childexpression, "Year");
Expand Down
2 changes: 1 addition & 1 deletion LinqToQuerystring/TreeNodes/Functions/YearsNode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public override Expression BuildLinqExpression(IQueryable query, Expression expr

if (!typeof(DateTime).IsAssignableFrom(childexpression.Type))
{
throw new FunctionNotSupportedException(childexpression.Type, "years");
childexpression = Expression.Convert(childexpression, typeof(DateTime));
}

return Expression.Property(childexpression, "Year");
Expand Down

0 comments on commit a117457

Please sign in to comment.