From fc02686937766dffaa58648f7083726db6a0caaa Mon Sep 17 00:00:00 2001 From: zqlovejyc <943620963@qq.com> Date: Thu, 12 Mar 2020 13:56:44 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E9=83=A8=E5=88=86=E6=83=85?= =?UTF-8?q?=E5=86=B5=E4=B8=8BContains=E6=96=B9=E6=B3=95=E8=A7=A3=E6=9E=90?= =?UTF-8?q?=E5=BC=82=E5=B8=B8bug=EF=BC=9B=E6=9B=B4=E6=96=B0=E7=89=88?= =?UTF-8?q?=E6=9C=AC=E5=8F=B7=E4=B8=BA1.0.3.5=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Expression/MethodCallExpressionResolve.cs | 69 ++++++++----------- SQLBuilder.Core/SQLBuilder.Core.csproj | 8 +-- 2 files changed, 34 insertions(+), 43 deletions(-) diff --git a/SQLBuilder.Core/Expression/MethodCallExpressionResolve.cs b/SQLBuilder.Core/Expression/MethodCallExpressionResolve.cs index 19b0fc2..3eca8dc 100644 --- a/SQLBuilder.Core/Expression/MethodCallExpressionResolve.cs +++ b/SQLBuilder.Core/Expression/MethodCallExpressionResolve.cs @@ -264,48 +264,39 @@ private static void Contains(MethodCallExpression expression, SqlPack sqlPack) { if (expression.Object != null) { - if (expression.Arguments[0].NodeType == ExpressionType.MemberAccess) + SqlBuilderProvider.Where(expression.Object, sqlPack); + switch (sqlPack.DatabaseType) { - SqlBuilderProvider.Where(expression.Arguments[0], sqlPack); - sqlPack += " IN "; - SqlBuilderProvider.In(expression.Object, sqlPack); + case DatabaseType.SQLServer: + sqlPack += " LIKE '%' + "; + break; + case DatabaseType.MySQL: + case DatabaseType.PostgreSQL: + sqlPack += " LIKE CONCAT('%',"; + break; + case DatabaseType.Oracle: + case DatabaseType.SQLite: + sqlPack += " LIKE '%' || "; + break; + default: + break; } - else + SqlBuilderProvider.Where(expression.Arguments[0], sqlPack); + switch (sqlPack.DatabaseType) { - SqlBuilderProvider.Where(expression.Object, sqlPack); - switch (sqlPack.DatabaseType) - { - case DatabaseType.SQLServer: - sqlPack += " LIKE '%' + "; - break; - case DatabaseType.MySQL: - case DatabaseType.PostgreSQL: - sqlPack += " LIKE CONCAT('%',"; - break; - case DatabaseType.Oracle: - case DatabaseType.SQLite: - sqlPack += " LIKE '%' || "; - break; - default: - break; - } - SqlBuilderProvider.Where(expression.Arguments[0], sqlPack); - switch (sqlPack.DatabaseType) - { - case DatabaseType.SQLServer: - sqlPack += " + '%'"; - break; - case DatabaseType.MySQL: - case DatabaseType.PostgreSQL: - sqlPack += ",'%')"; - break; - case DatabaseType.Oracle: - case DatabaseType.SQLite: - sqlPack += " || '%'"; - break; - default: - break; - } + case DatabaseType.SQLServer: + sqlPack += " + '%'"; + break; + case DatabaseType.MySQL: + case DatabaseType.PostgreSQL: + sqlPack += ",'%')"; + break; + case DatabaseType.Oracle: + case DatabaseType.SQLite: + sqlPack += " || '%'"; + break; + default: + break; } } else if (expression.Arguments.Count > 1 && expression.Arguments[1] is MemberExpression memberExpression) diff --git a/SQLBuilder.Core/SQLBuilder.Core.csproj b/SQLBuilder.Core/SQLBuilder.Core.csproj index cd14687..bbddf06 100644 --- a/SQLBuilder.Core/SQLBuilder.Core.csproj +++ b/SQLBuilder.Core/SQLBuilder.Core.csproj @@ -2,15 +2,15 @@ netstandard2.0 - 1.0.3.4 + 1.0.3.5 张强 - 1.0.3.4 + 1.0.3.5 true Expression表达式转换为SQL语句,支持SqlServer、MySQL、Oracle、SQLite、PostgreSQL Copyright © 2018-2020 , 张强 943620963@qq.com Zq.SQLBuilder.Core - 1.修复单个字段排序不起作用bug; - 1.0.3.4 + 1.修复部分情况下Contains方法解析异常bug; + 1.0.3.5 https://github.com/zqlovejyc/SQLBuilder.Core