Browse Source

fix(ef): 修复排序字段为空时的查询错误.

pull/918/head
colin 2 years ago
parent
commit
0b6c8150de
  1. 5
      aspnet-core/modules/identity/LINGYUN.Abp.Identity.EntityFrameworkCore/LINGYUN/Abp/Identity/EntityFrameworkCore/EfCoreOrganizationUnitRepository.cs
  2. 5
      aspnet-core/modules/identityServer/LINGYUN.Abp.IdentityServer.EntityFrameworkCore/LINGYUN/Abp/IdentityServer/Grants/EfCorePersistentGrantRepository.cs
  3. 7
      aspnet-core/modules/localization-management/LINGYUN.Abp.LocalizationManagement.EntityFrameworkCore/LINGYUN/Abp/LocalizationManagement/EntityFrameworkCore/EfCoreTextRepository.cs
  4. 2
      aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Layouts/Dto/GetLayoutListInput.cs
  5. 2
      aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Menus/Dto/MenuGetListInput.cs
  6. 4
      aspnet-core/modules/platform/LINGYUN.Platform.Application/LINGYUN/Platform/Menus/MenuAppService.cs
  7. 2
      aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Datas/IDataRepository.cs
  8. 1
      aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Layouts/ILayoutRepository.cs
  9. 2
      aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Menus/IMenuRepository.cs
  10. 10
      aspnet-core/modules/platform/LINGYUN.Platform.EntityFrameworkCore/LINGYUN/Platform/Datas/EfCoreDataRepository.cs
  11. 7
      aspnet-core/modules/platform/LINGYUN.Platform.EntityFrameworkCore/LINGYUN/Platform/Layouts/EfCoreLayoutRepository.cs
  12. 16
      aspnet-core/modules/platform/LINGYUN.Platform.EntityFrameworkCore/LINGYUN/Platform/Menus/EfCoreMenuRepository.cs
  13. 23
      aspnet-core/modules/realtime-message/LINGYUN.Abp.MessageService.EntityFrameworkCore/LINGYUN/Abp/MessageService/Chat/EfCoreMessageRepository.cs
  14. 6
      aspnet-core/modules/realtime-message/LINGYUN.Abp.MessageService.EntityFrameworkCore/LINGYUN/Abp/MessageService/Chat/EfCoreUserChatCardRepository.cs
  15. 12
      aspnet-core/modules/realtime-message/LINGYUN.Abp.MessageService.EntityFrameworkCore/LINGYUN/Abp/MessageService/Chat/EfCoreUserChatFriendRepository.cs
  16. 9
      aspnet-core/modules/realtime-message/LINGYUN.Abp.MessageService.EntityFrameworkCore/LINGYUN/Abp/MessageService/Groups/EfCoreGroupRepository.cs
  17. 6
      aspnet-core/modules/realtime-message/LINGYUN.Abp.MessageService.EntityFrameworkCore/LINGYUN/Abp/MessageService/Groups/EfCoreUserChatGroupRepository.cs
  18. 5
      aspnet-core/modules/realtime-notifications/LINGYUN.Abp.Notifications.EntityFrameworkCore/LINGYUN/Abp/Notifications/EntityFrameworkCore/EfCoreUserNotificationRepository.cs
  19. 6
      aspnet-core/modules/realtime-notifications/LINGYUN.Abp.Notifications.EntityFrameworkCore/LINGYUN/Abp/Notifications/EntityFrameworkCore/EfCoreUserSubscribeRepository.cs
  20. 6
      aspnet-core/modules/saas/LINGYUN.Abp.Saas.EntityFrameworkCore/LINGYUN/Abp/Saas/EntityFrameworkCore/EfCoreEditionRepository.cs
  21. 8
      aspnet-core/modules/saas/LINGYUN.Abp.Saas.EntityFrameworkCore/LINGYUN/Abp/Saas/EntityFrameworkCore/EfCoreTenantRepository.cs
  22. 6
      aspnet-core/modules/task-management/LINGYUN.Abp.TaskManagement.EntityFrameworkCore/LINGYUN/Abp/TaskManagement/EntityFrameworkCore/EfCoreBackgroundJobInfoRepository.cs
  23. 6
      aspnet-core/modules/task-management/LINGYUN.Abp.TaskManagement.EntityFrameworkCore/LINGYUN/Abp/TaskManagement/EntityFrameworkCore/EfCoreBackgroundJobLogRepository.cs
  24. 6
      aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.EntityFrameworkCore/LINGYUN/Abp/WebhooksManagement/EntityFrameworkCore/EfCoreWebhookSubscriptionRepository.cs

5
aspnet-core/modules/identity/LINGYUN.Abp.Identity.EntityFrameworkCore/LINGYUN/Abp/Identity/EntityFrameworkCore/EfCoreOrganizationUnitRepository.cs

@ -1,4 +1,5 @@
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Dynamic.Core;
@ -36,6 +37,10 @@ public class EfCoreOrganizationUnitRepository : Volo.Abp.Identity.EntityFramewor
bool includeDetails = false,
CancellationToken cancellationToken = default)
{
if (sorting.IsNullOrWhiteSpace())
{
sorting = nameof(OrganizationUnit.Code);
}
return await (await GetDbSetAsync())
.IncludeDetails(includeDetails)
.Where(specification.ToExpression())

5
aspnet-core/modules/identityServer/LINGYUN.Abp.IdentityServer.EntityFrameworkCore/LINGYUN/Abp/IdentityServer/Grants/EfCorePersistentGrantRepository.cs

@ -36,11 +36,14 @@ namespace LINGYUN.Abp.IdentityServer.Grants
public async virtual Task<List<PersistedGrant>> GetListAsync(string subjectId = null, string filter = null, string sorting = "CreationTime", int skipCount = 1, int maxResultCount = 10, CancellationToken cancellation = default)
{
if (sorting.IsNullOrWhiteSpace())
{
sorting = nameof(PersistedGrant.CreationTime);
}
return await (await GetDbSetAsync())
.WhereIf(!subjectId.IsNullOrWhiteSpace(), x => x.SubjectId.Equals(subjectId))
.WhereIf(!filter.IsNullOrWhiteSpace(), x =>
x.Type.Contains(filter) || x.ClientId.Contains(filter) || x.Key.Contains(filter))
.OrderBy(sorting ?? nameof(PersistedGrant.CreationTime))
.PageBy(skipCount, maxResultCount)
.ToListAsync(GetCancellationToken(cancellation));
}

7
aspnet-core/modules/localization-management/LINGYUN.Abp.LocalizationManagement.EntityFrameworkCore/LINGYUN/Abp/LocalizationManagement/EntityFrameworkCore/EfCoreTextRepository.cs

@ -121,11 +121,16 @@ namespace LINGYUN.Abp.LocalizationManagement.EntityFrameworkCore
string filter = null,
string sorting = nameof(TextDifference.Key))
{
if (sorting.IsNullOrWhiteSpace())
{
sorting = nameof(TextDifference.Key);
}
var textQuery = (await GetDbSetAsync())
.Where(x => x.CultureName.Equals(cultureName))
.WhereIf(!resourceName.IsNullOrWhiteSpace(), x => x.ResourceName.Equals(resourceName))
.WhereIf(!filter.IsNullOrWhiteSpace(), x => x.Key.Contains(filter))
.OrderBy(sorting ?? nameof(TextDifference.Key));
.OrderBy(sorting);
var targetTextQuery = (await GetDbSetAsync())
.Where(x => x.CultureName.Equals(targetCultureName))

2
aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Layouts/Dto/GetLayoutListInput.cs

@ -8,8 +8,6 @@ namespace LINGYUN.Platform.Layouts
{
public string Filter { get; set; }
public bool Reverse { get; set; }
[DynamicStringLength(typeof(LayoutConsts), nameof(LayoutConsts.MaxFrameworkLength))]
public string Framework { get; set; }
}

2
aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Menus/Dto/MenuGetListInput.cs

@ -12,8 +12,6 @@ namespace LINGYUN.Platform.Menus
public string Filter { get; set; }
public bool Reverse { get; set; }
public Guid? ParentId { get; set; }
public Guid? LayoutId { get; set; }

4
aspnet-core/modules/platform/LINGYUN.Platform.Application/LINGYUN/Platform/Menus/MenuAppService.cs

@ -86,7 +86,7 @@ namespace LINGYUN.Platform.Menus
public async virtual Task<ListResultDto<MenuDto>> GetAllAsync(MenuGetAllInput input)
{
var menus = await MenuRepository.GetAllAsync(
input.Filter, input.Sorting, input.Reverse,
input.Filter, input.Sorting,
input.Framework, input.ParentId, input.LayoutId);
return new ListResultDto<MenuDto>(
@ -99,7 +99,7 @@ namespace LINGYUN.Platform.Menus
var count = await MenuRepository.GetCountAsync(input.Filter, input.Framework, input.ParentId, input.LayoutId);
var menus = await MenuRepository.GetListAsync(
input.Filter, input.Sorting, input.Reverse,
input.Filter, input.Sorting,
input.Framework, input.ParentId, input.LayoutId,
input.SkipCount, input.MaxResultCount);

2
aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Datas/IDataRepository.cs

@ -25,7 +25,7 @@ namespace LINGYUN.Platform.Datas
Task<List<Data>> GetPagedListAsync(
string filter = "",
string sotring = nameof(Data.Code),
string sorting = nameof(Data.Code),
bool includeDetails = false,
int skipCount = 0,
int maxResultCount = 10,

1
aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Layouts/ILayoutRepository.cs

@ -29,7 +29,6 @@ namespace LINGYUN.Platform.Layouts
string framework = "",
string filter = "",
string sorting = nameof(Layout.Name),
bool reverse = false,
bool includeDetails = false,
int skipCount = 0,
int maxResultCount = 10,

2
aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Menus/IMenuRepository.cs

@ -95,7 +95,6 @@ namespace LINGYUN.Platform.Menus
Task<List<Menu>> GetListAsync(
string filter = "",
string sorting = nameof(Menu.Code),
bool reverse = false,
string framework = "",
Guid? parentId = null,
Guid? layoutId = null,
@ -106,7 +105,6 @@ namespace LINGYUN.Platform.Menus
Task<List<Menu>> GetAllAsync(
string filter = "",
string sorting = nameof(Menu.Code),
bool reverse = false,
string framework = "",
Guid? parentId = null,
Guid? layoutId = null,

10
aspnet-core/modules/platform/LINGYUN.Platform.EntityFrameworkCore/LINGYUN/Platform/Datas/EfCoreDataRepository.cs

@ -8,6 +8,7 @@ using System.Threading;
using System.Threading.Tasks;
using Volo.Abp.Domain.Repositories.EntityFrameworkCore;
using Volo.Abp.EntityFrameworkCore;
using static System.Runtime.InteropServices.JavaScript.JSType;
namespace LINGYUN.Platform.Datas
{
@ -56,13 +57,16 @@ namespace LINGYUN.Platform.Datas
public async virtual Task<List<Data>> GetPagedListAsync(
string filter = "",
string sotring = "Code",
string sorting = "Code",
bool includeDetails = false,
int skipCount = 0,
int maxResultCount = 10,
CancellationToken cancellationToken = default)
{
sotring ??= nameof(Data.Code);
if (sorting.IsNullOrWhiteSpace())
{
sorting = nameof(Data.Code);
}
var dbSet = await GetDbSetAsync();
return await dbSet
@ -70,7 +74,7 @@ namespace LINGYUN.Platform.Datas
.WhereIf(!filter.IsNullOrWhiteSpace(), x =>
x.Code.Contains(filter) || x.Description.Contains(filter) ||
x.DisplayName.Contains(filter) || x.Name.Contains(filter))
.OrderBy(sotring)
.OrderBy(sorting)
.PageBy(skipCount, maxResultCount)
.ToListAsync(GetCancellationToken(cancellationToken));
}

7
aspnet-core/modules/platform/LINGYUN.Platform.EntityFrameworkCore/LINGYUN/Platform/Layouts/EfCoreLayoutRepository.cs

@ -46,14 +46,15 @@ namespace LINGYUN.Platform.Layouts
string framework = "",
string filter = "",
string sorting = nameof(Layout.Name),
bool reverse = false,
bool includeDetails = false,
int skipCount = 0,
int maxResultCount = 10,
CancellationToken cancellationToken = default)
{
sorting ??= nameof(Layout.Name);
sorting = reverse ? sorting + " DESC" : sorting;
if (sorting.IsNullOrWhiteSpace())
{
sorting = nameof(Layout.Name);
}
return await (await GetDbSetAsync())
.IncludeDetails(includeDetails)

16
aspnet-core/modules/platform/LINGYUN.Platform.EntityFrameworkCore/LINGYUN/Platform/Menus/EfCoreMenuRepository.cs

@ -165,14 +165,15 @@ namespace LINGYUN.Platform.Menus
public async virtual Task<List<Menu>> GetAllAsync(
string filter = "",
string sorting = nameof(Menu.Code),
bool reverse = false,
string framework = "",
Guid? parentId = null,
Guid? layoutId = null,
CancellationToken cancellationToken = default)
{
sorting ??= nameof(Menu.Code);
sorting = reverse ? sorting + " DESC" : sorting;
if (sorting.IsNullOrWhiteSpace())
{
sorting = nameof(Menu.Code);
}
return await (await GetDbSetAsync())
.WhereIf(parentId.HasValue, x => x.ParentId == parentId)
@ -182,7 +183,7 @@ namespace LINGYUN.Platform.Menus
menu.Path.Contains(filter) || menu.Name.Contains(filter) ||
menu.DisplayName.Contains(filter) || menu.Description.Contains(filter) ||
menu.Redirect.Contains(filter))
.OrderBy(sorting)
.rting)
.ToListAsync(GetCancellationToken(cancellationToken));
}
@ -207,7 +208,6 @@ namespace LINGYUN.Platform.Menus
public async virtual Task<List<Menu>> GetListAsync(
string filter = "",
string sorting = nameof(Menu.Code),
bool reverse = false,
string framework = "",
Guid? parentId = null,
Guid? layoutId = null,
@ -215,8 +215,10 @@ namespace LINGYUN.Platform.Menus
int maxResultCount = 10,
CancellationToken cancellationToken = default)
{
sorting ??= nameof(Menu.Code);
sorting = reverse ? sorting + " DESC" : sorting;
if (sorting.IsNullOrWhiteSpace())
{
sorting = nameof(Menu.Code);
}
return await (await GetDbSetAsync())
.WhereIf(parentId.HasValue, x => x.ParentId == parentId)

23
aspnet-core/modules/realtime-message/LINGYUN.Abp.MessageService.EntityFrameworkCore/LINGYUN/Abp/MessageService/Chat/EfCoreMessageRepository.cs

@ -49,13 +49,17 @@ namespace LINGYUN.Abp.MessageService.Chat
int maxResultCount = 10,
CancellationToken cancellationToken = default)
{
if (sorting.IsNullOrWhiteSpace())
{
sorting = nameof(GroupMessage.MessageId);
}
var groupMessages = await (await GetDbContextAsync()).Set<GroupMessage>()
.Distinct()
.Where(x => x.GroupId.Equals(groupId))
.Where(x => x.State == MessageState.Send || x.State == MessageState.Read)
.WhereIf(type.HasValue, x => x.Type.Equals(type))
.WhereIf(!filter.IsNullOrWhiteSpace(), x => x.Content.Contains(filter) || x.SendUserName.Contains(filter))
.OrderBy(sorting ?? nameof(GroupMessage.MessageId))
.OrderBy(sorting)
.PageBy(skipCount, maxResultCount)
.AsNoTracking()
.ToListAsync(GetCancellationToken(cancellationToken));
@ -89,12 +93,16 @@ namespace LINGYUN.Abp.MessageService.Chat
int maxResultCount = 10,
CancellationToken cancellationToken = default)
{
if (sorting.IsNullOrWhiteSpace())
{
sorting = nameof(GroupMessage.MessageId);
}
var groupMessages = await (await GetDbContextAsync()).Set<GroupMessage>()
.Distinct()
.Where(x => x.GroupId.Equals(groupId) && x.CreatorId.Equals(sendUserId))
.WhereIf(type != null, x => x.Type.Equals(type))
.WhereIf(!filter.IsNullOrWhiteSpace(), x => x.Content.Contains(filter) || x.SendUserName.Contains(filter))
.OrderBy(sorting ?? nameof(GroupMessage.MessageId))
.OrderBy(sorting)
.PageBy(skipCount, maxResultCount)
.AsNoTracking()
.ToListAsync(GetCancellationToken(cancellationToken));
@ -162,7 +170,10 @@ namespace LINGYUN.Abp.MessageService.Chat
int maxResultCount = 10,
CancellationToken cancellationToken = default)
{
sorting ??= $"{nameof(LastChatMessage.SendTime)} DESC";
if (sorting.IsNullOrWhiteSpace())
{
sorting = $"{nameof(LastChatMessage.SendTime)} DESC";
}
var dbContext = await GetDbContextAsync();
#region SQL 原型
@ -439,13 +450,17 @@ namespace LINGYUN.Abp.MessageService.Chat
int maxResultCount = 10,
CancellationToken cancellationToken = default)
{
if (sorting.IsNullOrWhiteSpace())
{
sorting = nameof(UserMessage.MessageId);
}
var userMessages = await (await GetDbContextAsync()).Set<UserMessage>()
.Where(x => (x.CreatorId.Equals(sendUserId) && x.ReceiveUserId.Equals(receiveUserId)) ||
x.CreatorId.Equals(receiveUserId) && x.ReceiveUserId.Equals(sendUserId))
.WhereIf(type.HasValue, x => x.Type.Equals(type))
.Where(x => x.State == MessageState.Send || x.State == MessageState.Read)
.WhereIf(!filter.IsNullOrWhiteSpace(), x => x.Content.Contains(filter) || x.SendUserName.Contains(filter))
.OrderBy(sorting ?? nameof(UserMessage.MessageId))
.OrderBy(sorting)
.PageBy(skipCount, maxResultCount)
.AsNoTracking()
.ToListAsync(GetCancellationToken(cancellationToken));

6
aspnet-core/modules/realtime-message/LINGYUN.Abp.MessageService.EntityFrameworkCore/LINGYUN/Abp/MessageService/Chat/EfCoreUserChatCardRepository.cs

@ -69,12 +69,16 @@ namespace LINGYUN.Abp.MessageService.Chat
int maxResultCount = 10,
CancellationToken cancellationToken = default)
{
if (sorting.IsNullOrWhiteSpace())
{
sorting = nameof(UserChatCard.UserId);
}
return await (await GetDbSetAsync())
.WhereIf(!findUserName.IsNullOrWhiteSpace(), ucc => ucc.UserName.Contains(findUserName))
.WhereIf(startAge.HasValue, ucc => ucc.Age >= startAge.Value)
.WhereIf(endAge.HasValue, ucc => ucc.Age <= endAge.Value)
.WhereIf(sex.HasValue, ucc => ucc.Sex == sex)
.OrderBy(sorting ?? nameof(UserChatCard.UserId))
.OrderBy(sorting)
.PageBy(skipCount, maxResultCount)
.Select(ucc => ucc.ToUserCard())
.ToListAsync(GetCancellationToken(cancellationToken));

12
aspnet-core/modules/realtime-message/LINGYUN.Abp.MessageService.EntityFrameworkCore/LINGYUN/Abp/MessageService/Chat/EfCoreUserChatFriendRepository.cs

@ -33,6 +33,10 @@ namespace LINGYUN.Abp.MessageService.Chat
string sorting = nameof(UserChatFriend.RemarkName),
CancellationToken cancellationToken = default)
{
if (sorting.IsNullOrWhiteSpace())
{
sorting = nameof(UserChatFriend.RemarkName);
}
var dbContext = await GetDbContextAsync();
var userFriendQuery = from ucf in dbContext.Set<UserChatFriend>()
join ucc in dbContext.Set<UserChatCard>()
@ -60,7 +64,7 @@ namespace LINGYUN.Abp.MessageService.Chat
};
return await userFriendQuery
.OrderBy(sorting ?? nameof(UserChatFriend.RemarkName))
.OrderBy(sorting)
.ToListAsync(GetCancellationToken(cancellationToken));
}
@ -103,6 +107,10 @@ namespace LINGYUN.Abp.MessageService.Chat
int maxResultCount = 10,
CancellationToken cancellationToken = default)
{
if (sorting.IsNullOrWhiteSpace())
{
sorting = nameof(UserChatFriend.UserId);
}
var dbContext = await GetDbContextAsync();
// 过滤用户资料
var userChatCardQuery = dbContext.Set<UserChatCard>()
@ -139,7 +147,7 @@ namespace LINGYUN.Abp.MessageService.Chat
};
return await userFriendQuery
.OrderBy(sorting ?? nameof(UserChatFriend.UserId))
.OrderBy(sorting)
.PageBy(skipCount, maxResultCount)
.ToListAsync(GetCancellationToken(cancellationToken));
}

9
aspnet-core/modules/realtime-message/LINGYUN.Abp.MessageService.EntityFrameworkCore/LINGYUN/Abp/MessageService/Groups/EfCoreGroupRepository.cs

@ -1,4 +1,5 @@
using LINGYUN.Abp.MessageService.EntityFrameworkCore;
using LINGYUN.Abp.MessageService.Chat;
using LINGYUN.Abp.MessageService.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
@ -38,10 +39,14 @@ namespace LINGYUN.Abp.MessageService.Groups
int maxResultCount = 10,
CancellationToken cancellationToken = default)
{
if (sorting.IsNullOrWhiteSpace())
{
sorting = nameof(ChatGroup.Name);
}
return await (await GetDbSetAsync())
.WhereIf(!filter.IsNullOrWhiteSpace(), x =>
x.Name.Contains(filter) || x.Tag.Contains(filter))
.OrderBy(sorting ?? nameof(ChatGroup.Name))
.OrderBy(sorting)
.PageBy(skipCount, maxResultCount)
.ToListAsync(GetCancellationToken(cancellationToken));
}

6
aspnet-core/modules/realtime-message/LINGYUN.Abp.MessageService.EntityFrameworkCore/LINGYUN/Abp/MessageService/Groups/EfCoreUserChatGroupRepository.cs

@ -64,6 +64,10 @@ namespace LINGYUN.Abp.MessageService.Groups
int maxResultCount = 10,
CancellationToken cancellationToken = default)
{
if (sorting.IsNullOrWhiteSpace())
{
sorting = nameof(UserChatCard.UserId);
}
var dbContext = await GetDbContextAsync();
var cardQuery = from gp in dbContext.Set<ChatGroup>()
join ucg in dbContext.Set<UserChatGroup>()
@ -91,7 +95,7 @@ namespace LINGYUN.Abp.MessageService.Groups
};
return await cardQuery
.OrderBy(sorting ?? nameof(UserChatCard.UserId))
.OrderBy(sorting)
.PageBy(skipCount, maxResultCount)
.ToListAsync(GetCancellationToken(cancellationToken));
}

5
aspnet-core/modules/realtime-notifications/LINGYUN.Abp.Notifications.EntityFrameworkCore/LINGYUN/Abp/Notifications/EntityFrameworkCore/EfCoreUserNotificationRepository.cs

@ -150,7 +150,10 @@ public class EfCoreUserNotificationRepository : EfCoreRepository<INotificationsD
int maxResultCount = 10,
CancellationToken cancellationToken = default)
{
sorting ??= $"{nameof(Notification.CreationTime)} DESC";
if (sorting.IsNullOrWhiteSpace())
{
sorting = $"{nameof(Notification.CreationTime)} DESC";
}
var dbContext = await GetDbContextAsync();
//var userNotifilerQuery = dbContext.Set<UserNotification>()
// .Where(x => x.UserId == userId)

6
aspnet-core/modules/realtime-notifications/LINGYUN.Abp.Notifications.EntityFrameworkCore/LINGYUN/Abp/Notifications/EntityFrameworkCore/EfCoreUserSubscribeRepository.cs

@ -137,10 +137,14 @@ public class EfCoreUserSubscribeRepository : EfCoreRepository<INotificationsDbCo
int maxResultCount = 10,
CancellationToken cancellationToken = default)
{
if (sorting.IsNullOrWhiteSpace())
{
sorting = nameof(UserSubscribe.Id);
}
var userSubscribes = await (await GetDbSetAsync())
.Distinct()
.Where(x => x.UserId.Equals(userId))
.OrderBy(sorting ?? nameof(UserSubscribe.Id))
.OrderBy(sorting)
.Page(skipCount, maxResultCount)
.AsNoTracking()
.ToListAsync(GetCancellationToken(cancellationToken));

6
aspnet-core/modules/saas/LINGYUN.Abp.Saas.EntityFrameworkCore/LINGYUN/Abp/Saas/EntityFrameworkCore/EfCoreEditionRepository.cs

@ -75,9 +75,13 @@ public class EfCoreEditionRepository : EfCoreRepository<ISaasDbContext, Edition,
string filter = null,
CancellationToken cancellationToken = default)
{
if (sorting.IsNullOrWhiteSpace())
{
sorting = nameof(Edition.DisplayName);
}
return await (await GetDbSetAsync())
.WhereIf(!filter.IsNullOrWhiteSpace(), x => x.DisplayName.Contains(filter))
.OrderBy(sorting.IsNullOrEmpty() ? nameof(Edition.DisplayName) : sorting)
.OrderBy(sorting)
.PageBy(skipCount, maxResultCount)
.ToListAsync(GetCancellationToken(cancellationToken));
}

8
aspnet-core/modules/saas/LINGYUN.Abp.Saas.EntityFrameworkCore/LINGYUN/Abp/Saas/EntityFrameworkCore/EfCoreTenantRepository.cs

@ -168,6 +168,10 @@ public class EfCoreTenantRepository : EfCoreRepository<ISaasDbContext, Tenant, G
bool includeDetails = false,
CancellationToken cancellationToken = default)
{
if (sorting.IsNullOrWhiteSpace())
{
sorting = nameof(Tenant.Name);
}
if (includeDetails)
{
var dbContext = await GetDbContextAsync();
@ -177,7 +181,7 @@ public class EfCoreTenantRepository : EfCoreRepository<ISaasDbContext, Tenant, G
tenantDbSet = tenantDbSet
.WhereIf(!filter.IsNullOrWhiteSpace(), u => u.Name.Contains(filter))
.OrderBy(sorting.IsNullOrEmpty() ? nameof(Tenant.Name) : sorting);
.OrderBy(sorting);
var combinedResult = await (from tenant in tenantDbSet
join edition in editionDbSet on tenant.EditionId equals edition.Id
@ -210,7 +214,7 @@ public class EfCoreTenantRepository : EfCoreRepository<ISaasDbContext, Tenant, G
return await (await GetDbSetAsync())
.WhereIf(!filter.IsNullOrWhiteSpace(), u => u.Name.Contains(filter))
.OrderBy(sorting.IsNullOrEmpty() ? nameof(Tenant.Name) : sorting)
.OrderBy(sorting)
.PageBy(skipCount, maxResultCount)
.ToListAsync(GetCancellationToken(cancellationToken));
}

6
aspnet-core/modules/task-management/LINGYUN.Abp.TaskManagement.EntityFrameworkCore/LINGYUN/Abp/TaskManagement/EntityFrameworkCore/EfCoreBackgroundJobInfoRepository.cs

@ -81,9 +81,13 @@ public class EfCoreBackgroundJobInfoRepository :
public async virtual Task<List<BackgroundJobInfo>> GetListAsync(ISpecification<BackgroundJobInfo> specification, string sorting = "Name", int maxResultCount = 10, int skipCount = 0, CancellationToken cancellationToken = default)
{
if (sorting.IsNullOrWhiteSpace())
{
sorting = $"{nameof(BackgroundJobInfo.CreationTime)} DESC";
}
return await (await GetDbSetAsync())
.Where(specification.ToExpression())
.OrderBy(sorting ?? $"{nameof(BackgroundJobInfo.CreationTime)} DESC")
.OrderBy(sorting)
.PageBy(skipCount, maxResultCount)
.ToListAsync(GetCancellationToken(cancellationToken));
}

6
aspnet-core/modules/task-management/LINGYUN.Abp.TaskManagement.EntityFrameworkCore/LINGYUN/Abp/TaskManagement/EntityFrameworkCore/EfCoreBackgroundJobLogRepository.cs

@ -46,6 +46,10 @@ public class EfCoreBackgroundJobLogRepository :
int skipCount = 0,
CancellationToken cancellationToken = default)
{
if (sorting.IsNullOrWhiteSpace())
{
sorting = $"{nameof(BackgroundJobLog.RunTime)}";
}
return await (await GetDbSetAsync())
.WhereIf(!jobId.IsNullOrWhiteSpace(), x => x.JobId.Equals(jobId))
.WhereIf(!filter.Type.IsNullOrWhiteSpace(), x => x.JobType.Contains(filter.Type))
@ -56,7 +60,7 @@ public class EfCoreBackgroundJobLogRepository :
.WhereIf(filter.HasExceptions.HasValue, x => !string.IsNullOrWhiteSpace(x.Exception))
.WhereIf(filter.BeginRunTime.HasValue, x => x.RunTime.CompareTo(filter.BeginRunTime.Value) >= 0)
.WhereIf(filter.EndRunTime.HasValue, x => x.RunTime.CompareTo(filter.EndRunTime.Value) <= 0)
.OrderBy(sorting ?? $"{nameof(BackgroundJobLog.RunTime)} DESC")
.OrderBy(sorting)
.PageBy(skipCount, maxResultCount)
.ToListAsync(GetCancellationToken(cancellationToken));
}

6
aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.EntityFrameworkCore/LINGYUN/Abp/WebhooksManagement/EntityFrameworkCore/EfCoreWebhookSubscriptionRepository.cs

@ -50,9 +50,13 @@ public class EfCoreWebhookSubscriptionRepository :
int skipCount = 0,
CancellationToken cancellationToken = default)
{
if (sorting.IsNullOrWhiteSpace())
{
sorting = $"{nameof(WebhookSubscription.CreationTime)} DESC";
}
return await (await GetDbSetAsync())
.Where(specification.ToExpression())
.OrderBy(sorting ?? $"{nameof(WebhookSubscription.CreationTime)} DESC")
.OrderBy(sorting)
.PageBy(skipCount, maxResultCount)
.ToListAsync(GetCancellationToken(cancellationToken));
}

Loading…
Cancel
Save