Skip to content

Commit

Permalink
修复部分情况下Contains方法解析异常bug;更新版本号为1.0.3.5;
Browse files Browse the repository at this point in the history
  • Loading branch information
zqlovejyc committed Mar 12, 2020
1 parent 063b3b5 commit fc02686
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 43 deletions.
69 changes: 30 additions & 39 deletions SQLBuilder.Core/Expression/MethodCallExpressionResolve.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
8 changes: 4 additions & 4 deletions SQLBuilder.Core/SQLBuilder.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<AssemblyVersion>1.0.3.4</AssemblyVersion>
<AssemblyVersion>1.0.3.5</AssemblyVersion>
<Authors>张强</Authors>
<Version>1.0.3.4</Version>
<Version>1.0.3.5</Version>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Description>Expression表达式转换为SQL语句,支持SqlServer、MySQL、Oracle、SQLite、PostgreSQL</Description>
<Copyright>Copyright © 2018-2020 , 张强 [email protected]</Copyright>
<PackageId>Zq.SQLBuilder.Core</PackageId>
<PackageReleaseNotes>1.修复单个字段排序不起作用bug;</PackageReleaseNotes>
<FileVersion>1.0.3.4</FileVersion>
<PackageReleaseNotes>1.修复部分情况下Contains方法解析异常bug;</PackageReleaseNotes>
<FileVersion>1.0.3.5</FileVersion>
<PackageProjectUrl>https://github.com/zqlovejyc/SQLBuilder.Core</PackageProjectUrl>
</PropertyGroup>

Expand Down

0 comments on commit fc02686

Please sign in to comment.