private IProjection DatePartMethod(DatePartMethod method, Expression[] arguments, string function) { return(new SqlFunctionProjection( function, NHibernateUtil.Int32, ProjectionVisitor.CreateProjection(arguments[0]) )); }
private Expression NormalizeDatePart(DatePartMethod method, LiteralExpression[] arguments) { if (LiteralUtil.IsAnyNull(arguments)) { return(new LiteralExpression(null, LiteralType.Null)); } else if (arguments[0].LiteralType != LiteralType.DateTime) { throw new ODataException(String.Format( ErrorMessages.Method_InvalidArgumentType, method.MethodType, 1, "Edm.DateTime" )); } else { var argument = (DateTime)arguments[0].Value; int result; switch (method.MethodType) { case MethodType.Year: result = argument.Year; break; case MethodType.Month: result = argument.Month; break; case MethodType.Day: result = argument.Day; break; case MethodType.Hour: result = argument.Hour; break; case MethodType.Minute: result = argument.Minute; break; case MethodType.Second: result = argument.Second; break; default: throw new NotSupportedException(); } return(new LiteralExpression(result, LiteralType.Int)); } }