diff --git a/LinqToQuerystring/TreeNodes/Functions/DayNode.cs b/LinqToQuerystring/TreeNodes/Functions/DayNode.cs index c669a62..4bfa1bd 100644 --- a/LinqToQuerystring/TreeNodes/Functions/DayNode.cs +++ b/LinqToQuerystring/TreeNodes/Functions/DayNode.cs @@ -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"); diff --git a/LinqToQuerystring/TreeNodes/Functions/DaysNode.cs b/LinqToQuerystring/TreeNodes/Functions/DaysNode.cs index 95e301d..db26031 100644 --- a/LinqToQuerystring/TreeNodes/Functions/DaysNode.cs +++ b/LinqToQuerystring/TreeNodes/Functions/DaysNode.cs @@ -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"); diff --git a/LinqToQuerystring/TreeNodes/Functions/HourNode.cs b/LinqToQuerystring/TreeNodes/Functions/HourNode.cs index 15233f5..f16c1ab 100644 --- a/LinqToQuerystring/TreeNodes/Functions/HourNode.cs +++ b/LinqToQuerystring/TreeNodes/Functions/HourNode.cs @@ -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"); diff --git a/LinqToQuerystring/TreeNodes/Functions/HoursNode.cs b/LinqToQuerystring/TreeNodes/Functions/HoursNode.cs index 5a7a4f2..e0ca84e 100644 --- a/LinqToQuerystring/TreeNodes/Functions/HoursNode.cs +++ b/LinqToQuerystring/TreeNodes/Functions/HoursNode.cs @@ -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"); diff --git a/LinqToQuerystring/TreeNodes/Functions/MinuteNode.cs b/LinqToQuerystring/TreeNodes/Functions/MinuteNode.cs index 797470d..35551bf 100644 --- a/LinqToQuerystring/TreeNodes/Functions/MinuteNode.cs +++ b/LinqToQuerystring/TreeNodes/Functions/MinuteNode.cs @@ -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"); diff --git a/LinqToQuerystring/TreeNodes/Functions/MinutesNode.cs b/LinqToQuerystring/TreeNodes/Functions/MinutesNode.cs index 41d1fa5..c5af75b 100644 --- a/LinqToQuerystring/TreeNodes/Functions/MinutesNode.cs +++ b/LinqToQuerystring/TreeNodes/Functions/MinutesNode.cs @@ -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"); diff --git a/LinqToQuerystring/TreeNodes/Functions/MonthNode.cs b/LinqToQuerystring/TreeNodes/Functions/MonthNode.cs index 5ab5f52..dec4050 100644 --- a/LinqToQuerystring/TreeNodes/Functions/MonthNode.cs +++ b/LinqToQuerystring/TreeNodes/Functions/MonthNode.cs @@ -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"); diff --git a/LinqToQuerystring/TreeNodes/Functions/SecondNode.cs b/LinqToQuerystring/TreeNodes/Functions/SecondNode.cs index 3f97d8a..dd15597 100644 --- a/LinqToQuerystring/TreeNodes/Functions/SecondNode.cs +++ b/LinqToQuerystring/TreeNodes/Functions/SecondNode.cs @@ -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"); diff --git a/LinqToQuerystring/TreeNodes/Functions/SecondsNode.cs b/LinqToQuerystring/TreeNodes/Functions/SecondsNode.cs index 8eebb8d..00122bd 100644 --- a/LinqToQuerystring/TreeNodes/Functions/SecondsNode.cs +++ b/LinqToQuerystring/TreeNodes/Functions/SecondsNode.cs @@ -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"); diff --git a/LinqToQuerystring/TreeNodes/Functions/YearNode.cs b/LinqToQuerystring/TreeNodes/Functions/YearNode.cs index ee5d480..4aa39f1 100644 --- a/LinqToQuerystring/TreeNodes/Functions/YearNode.cs +++ b/LinqToQuerystring/TreeNodes/Functions/YearNode.cs @@ -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"); diff --git a/LinqToQuerystring/TreeNodes/Functions/YearsNode.cs b/LinqToQuerystring/TreeNodes/Functions/YearsNode.cs index 0188725..7a9b580 100644 --- a/LinqToQuerystring/TreeNodes/Functions/YearsNode.cs +++ b/LinqToQuerystring/TreeNodes/Functions/YearsNode.cs @@ -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");