private static void Contains(MethodCallExpression expression, SqlPack sqlPack) { MethodInfo method = expression.Method; if (method.DeclaringType == typeof(String) || method.DeclaringType == typeof(string)) { if (expression.Object != null) { FluentExpressionSQLProvider.Where(expression.Object, sqlPack); } string result = ""; var column = expression.Arguments[0].GetValueOrColumnName(sqlPack); result = sqlPack.SqlDialectProvider.ConvertDbFunction(DbFunctionType.Contains, column); sqlPack += " LIKE "; sqlPack.CurrentDbFunctionResult = result; } else { var declaringType = method.DeclaringType; // typeof(IList).IsAssignableFrom(declaringType) || typeof(IEnumerable).IsAssignableFrom(declaringType) || (declaringType.IsGenericType && typeof(ICollection<>).MakeGenericType(declaringType.GetGenericArguments()).IsAssignableFrom(declaringType)) if (declaringType.IsListType()) { var memberExp = expression.Object; FluentExpressionSQLProvider.Where(expression.Arguments[0], sqlPack); sqlPack += " IN "; FluentExpressionSQLProvider.In(memberExp, sqlPack); } else if (method.IsStatic && declaringType == typeof(System.Linq.Enumerable) && expression.Arguments.Count == 2) { FluentExpressionSQLProvider.Where(expression.Arguments[1], sqlPack); sqlPack += " IN "; FluentExpressionSQLProvider.In(expression.Arguments[0], sqlPack); } } //sqlPack += " LIKE '%' +"; //FluentExpressionSQLProvider.Where(expression.Arguments[0], sqlPack); //sqlPack += " + '%'"; }
private static void InNot(MethodCallExpression expression, SqlPack sqlPack) { FluentExpressionSQLProvider.Where(expression.Arguments[0], sqlPack); sqlPack += " NOT IN "; FluentExpressionSQLProvider.In(expression.Arguments[1], sqlPack); }