static void Method_DbFunctions_DiffMicroseconds(DbMethodCallExpression exp, SqlGenerator generator) { EnsureMethod(exp, UtilConstants.MethodInfo_DbFunctions_DiffMicroseconds); throw UtilExceptions.NotSupportedMethod(exp.Method); }
static void Method_DateTime_AddMilliseconds(DbMethodCallExpression exp, SqlGenerator generator) { EnsureMethodDeclaringType(exp, UtilConstants.TypeOfDateTime); throw UtilExceptions.NotSupportedMethod(exp.Method); }
static void Method_DiffMicroseconds(DbMethodCallExpression exp, SqlGenerator generator) { EnsureMethodDeclaringType(exp, typeof(DbFunctions), UtilConstants.TypeOfSql); throw UtilExceptions.NotSupportedMethod(exp.Method); }
static void Method_Contains(DbMethodCallExpression exp, SqlGenerator generator) { MethodInfo method = exp.Method; if (method.DeclaringType == UtilConstants.TypeOfString) { Method_String_Contains(exp, generator); return; } List <DbExpression> exps = new List <DbExpression>(); IEnumerable values = null; DbExpression operand = null; Type declaringType = method.DeclaringType; if (typeof(IList).IsAssignableFrom(declaringType) || (declaringType.IsGenericType && typeof(ICollection <>).MakeGenericType(declaringType.GetGenericArguments()).IsAssignableFrom(declaringType))) { if (exp.Object.NodeType == DbExpressionType.SqlQuery) { /* where Id in(select id from T) */ operand = exp.Arguments[0]; In(generator, (DbSqlQueryExpression)exp.Object, operand); return; } DbMemberExpression memberExp = exp.Object as DbMemberExpression; if (memberExp == null || !memberExp.IsEvaluable()) { throw new NotSupportedException(exp.ToString()); } values = DbExpressionExtension.Evaluate(memberExp) as IEnumerable; //Enumerable operand = exp.Arguments[0]; goto constructInState; } if (method.IsStatic && declaringType == typeof(Enumerable) && exp.Arguments.Count == 2) { DbExpression arg0 = exp.Arguments[0]; if (arg0.NodeType == DbExpressionType.SqlQuery) { /* where Id in(select id from T) */ operand = exp.Arguments[1]; In(generator, (DbSqlQueryExpression)arg0, operand); return; } DbMemberExpression memberExp = arg0 as DbMemberExpression; if (memberExp == null || !memberExp.IsEvaluable()) { throw new NotSupportedException(exp.ToString()); } values = DbExpressionExtension.Evaluate(memberExp) as IEnumerable; operand = exp.Arguments[1]; goto constructInState; } throw UtilExceptions.NotSupportedMethod(exp.Method); constructInState: foreach (object value in values) { if (value == null) { exps.Add(DbExpression.Constant(null, operand.Type)); } else { Type valueType = value.GetType(); if (valueType.IsEnum) { valueType = Enum.GetUnderlyingType(valueType); } if (Utils.IsToStringableNumericType(valueType)) { exps.Add(DbExpression.Constant(value)); } else { exps.Add(DbExpression.Parameter(value)); } } } In(generator, exps, operand); }
static void Method_DiffMonths(DbMethodCallExpression exp, SqlGenerator generator) { EnsureMethodDeclaringType(exp, UtilConstants.TypeOfSql); throw UtilExceptions.NotSupportedMethod(exp.Method); }