Skip to content

Commit

Permalink
数字型主键,默认主键降序,赋值给OrderBy。如果用户代码自定义排序时赋值给Sort,会自动清空OrderBy。推荐用户自定义排序赋值给…
Browse files Browse the repository at this point in the history
…OrderBy,它有更高优先级
  • Loading branch information
nnhy committed Feb 16, 2024
1 parent 4985b58 commit 10a1205
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 16 deletions.
2 changes: 1 addition & 1 deletion CubeSSO/CubeSSO.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="NewLife.Core" Version="10.7.2024.202" />
<PackageReference Include="NewLife.Core" Version="10.7.2024.216-beta0739" />
<PackageReference Include="NewLife.Stardust.Extensions" Version="2.9.2024.101" />
</ItemGroup>

Expand Down
7 changes: 4 additions & 3 deletions NewLife.Cube/Common/ReadOnlyEntityController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -151,13 +151,14 @@ protected virtual IEnumerable<TEntity> SearchData(Pager p)
}

// 数字型主键,默认降序
if (p.Sort.IsNullOrEmpty())
if (p.Sort.IsNullOrEmpty() && p.OrderBy.IsNullOrEmpty())
{
var uk = Factory.Unique;
if (uk != null && uk.Type.IsInt())
{
p.Sort = uk.Name;
p.Desc = true;
p.OrderBy = uk.Desc();
//p.Sort = uk.Name;
//p.Desc = true;
}
}

Expand Down
2 changes: 1 addition & 1 deletion NewLife.Cube/Extensions/Pager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public Pager(IDictionary<String, String> parameters)
if (parameters.TryGetValue(nameof(Desc), out str)) Desc = str.ToBoolean();
if (parameters.TryGetValue(nameof(StartRow), out str)) StartRow = str.ToLong();
if (parameters.TryGetValue(nameof(Sort), out str)) Sort = str;
if (parameters.TryGetValue(nameof(OrderBy), out str)) OrderBy = str;
//if (parameters.TryGetValue(nameof(OrderBy), out str)) OrderBy = str;

Params = parameters;
}
Expand Down
4 changes: 2 additions & 2 deletions NewLife.Cube/NewLife.Cube.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,11 @@
<Compile Include="..\NewLife.CubeNC\WebMiddleware\TenantMiddleware.cs" Link="WebMiddleware\TenantMiddleware.cs" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="NewLife.Core" Version="10.7.2024.202" />
<PackageReference Include="NewLife.Core" Version="10.7.2024.216-beta0739" />
<PackageReference Include="NewLife.IP" Version="2.1.2024.101" />
<PackageReference Include="NewLife.Redis.Extensions" Version="5.5.2024.203" />
<PackageReference Include="NewLife.Stardust" Version="2.9.2024.101" />
<PackageReference Include="NewLife.XCode" Version="11.10.2024.203" />
<PackageReference Include="NewLife.XCode" Version="11.10.2024.216-beta0839" />
</ItemGroup>

<ItemGroup>
Expand Down
7 changes: 4 additions & 3 deletions NewLife.CubeNC/Common/ReadOnlyEntityController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -165,13 +165,14 @@ protected virtual IEnumerable<TEntity> SearchData(Pager p)
}

// 数字型主键,默认降序
if (p.Sort.IsNullOrEmpty())
if (p.Sort.IsNullOrEmpty() && p.OrderBy.IsNullOrEmpty())
{
var uk = Factory.Unique;
if (uk != null && uk.Type.IsInt())
{
p.Sort = uk.Name;
p.Desc = true;
p.OrderBy = uk.Desc();
//p.Sort = uk.Name;
//p.Desc = true;
}
}

Expand Down
4 changes: 2 additions & 2 deletions NewLife.CubeNC/NewLife.CubeNC.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@
</PackageReference>
</ItemGroup>
<ItemGroup>
<PackageReference Include="NewLife.Core" Version="10.7.2024.202" />
<PackageReference Include="NewLife.Core" Version="10.7.2024.216-beta0739" />
<PackageReference Include="NewLife.IP" Version="2.1.2024.101" />
<PackageReference Include="NewLife.Stardust" Version="2.9.2024.101" />
<PackageReference Include="NewLife.XCode" Version="11.10.2024.203" />
<PackageReference Include="NewLife.XCode" Version="11.10.2024.216-beta0839" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion NewLife.CubeNC/Services/JobService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public JobService(IServiceProvider serviceProvider, ITracer tracer)
/// <returns></returns>
public Task StartAsync(CancellationToken cancellationToken)
{
_timer = new TimerX(DoJob, null, 1_000, 600_000);
_timer = new TimerX(DoJob, null, 1_000, 600_000) { Async = true };

return Task.CompletedTask;
}
Expand Down
2 changes: 1 addition & 1 deletion Test/Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@
<None Remove="Entity\**" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="NewLife.XCode" Version="11.10.2024.203" />
<PackageReference Include="NewLife.XCode" Version="11.10.2024.216-beta0839" />
</ItemGroup>
</Project>
4 changes: 2 additions & 2 deletions XUnitTest/XUnitTest.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
<PackageReference Include="xunit" Version="2.6.6" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.6">
<PackageReference Include="xunit" Version="2.7.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.7">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
Expand Down

0 comments on commit 10a1205

Please sign in to comment.