Skip to content

Commit

Permalink
修复单个字段排序不起作用bug;
Browse files Browse the repository at this point in the history
  • Loading branch information
zqlovejyc committed Dec 30, 2019
1 parent 5432a9e commit c7672f6
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
2 changes: 2 additions & 0 deletions SQLBuilder.Core/Expression/ConstantExpressionResolve.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ public override SqlPack OrderBy(ConstantExpression expression, SqlPack sqlPack,
var tableAlias = sqlPack.GetTableAlias(tableName);
if (!string.IsNullOrEmpty(tableAlias)) tableAlias += ".";
sqlPack += tableAlias + expression.Value.ToString();
if (orders?.Length > 0)
sqlPack += $" { (orders[0] == OrderType.Descending ? "DESC" : "ASC")}";
return sqlPack;
}
#endregion
Expand Down
2 changes: 2 additions & 0 deletions SQLBuilder.Core/Expression/MemberExpressionResolve.cs
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,8 @@ public override SqlPack OrderBy(MemberExpression expression, SqlPack sqlPack, pa
if (expression.Expression.NodeType == ExpressionType.Parameter)
{
sqlPack += tableAlias + sqlPack.GetColumnInfo(expression.Member.DeclaringType, expression.Member, false).columnName;
if (orders?.Length > 0)
sqlPack += $" { (orders[0] == OrderType.Descending ? "DESC" : "ASC")}";
}
if (expression.Expression.NodeType == ExpressionType.Constant)
{
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.3</AssemblyVersion>
<AssemblyVersion>1.0.3.4</AssemblyVersion>
<Authors>张强</Authors>
<Version>1.0.3.3</Version>
<Version>1.0.3.4</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.修复实体bool类型字段解析sql错误bug;</PackageReleaseNotes>
<FileVersion>1.0.3.3</FileVersion>
<PackageReleaseNotes>1.修复单个字段排序不起作用bug;</PackageReleaseNotes>
<FileVersion>1.0.3.4</FileVersion>
<PackageProjectUrl>https://github.com/zqlovejyc/SQLBuilder.Core</PackageProjectUrl>
</PropertyGroup>

Expand Down

0 comments on commit c7672f6

Please sign in to comment.