Browse Source

queryOrder updated

pull/3509/head
Ahmet 6 years ago
parent
commit
3fe584f8f5
  1. 8
      modules/audit-logging/src/Volo.Abp.AuditLogging.EntityFrameworkCore/Volo/Abp/AuditLogging/EntityFrameworkCore/EfCoreAuditLogRepository.cs
  2. 7
      modules/audit-logging/src/Volo.Abp.AuditLogging.MongoDB/Volo/Abp/AuditLogging/MongoDB/MongoAuditLogRepository.cs
  3. 2
      modules/audit-logging/test/Volo.Abp.AuditLogging.TestBase/Volo/Abp/AuditLogging/AuditLogRepository_Tests.cs

8
modules/audit-logging/src/Volo.Abp.AuditLogging.EntityFrameworkCore/Volo/Abp/AuditLogging/EntityFrameworkCore/EfCoreAuditLogRepository.cs

@ -196,11 +196,15 @@ namespace Volo.Abp.AuditLogging.EntityFrameworkCore
public virtual async Task<List<EntityChangeWithUsername>> GetEntityChangesWithUsernameAsync(string entityId, string entityTypeFullName)
{
var query = DbContext.Set<EntityChange>().AsNoTracking().IncludeDetails().Where(x => x.EntityId == entityId && x.EntityTypeFullName == entityTypeFullName).OrderBy(x => x.ChangeTime);
var query = DbContext.Set<EntityChange>()
.AsNoTracking()
.IncludeDetails()
.Where(x => x.EntityId == entityId && x.EntityTypeFullName == entityTypeFullName);
return await (from e in query
join auditLog in DbSet on e.AuditLogId equals auditLog.Id
select new EntityChangeWithUsername() {EntityChange = e, UserName = auditLog.UserName}).ToListAsync();
select new EntityChangeWithUsername() {EntityChange = e, UserName = auditLog.UserName})
.OrderByDescending(x => x.EntityChange.ChangeTime).ToListAsync();
}
protected virtual IQueryable<EntityChange> GetEntityChangeListQuery(

7
modules/audit-logging/src/Volo.Abp.AuditLogging.MongoDB/Volo/Abp/AuditLogging/MongoDB/MongoAuditLogRepository.cs

@ -206,8 +206,11 @@ namespace Volo.Abp.AuditLogging.MongoDB
public virtual async Task<List<EntityChangeWithUsername>> GetEntityChangesWithUsernameAsync(string entityId, string entityTypeFullName)
{
var auditLogs = await GetMongoQueryable().Where(x =>
x.EntityChanges.Any(y => y.EntityId == entityId && y.EntityTypeFullName == entityTypeFullName)).As<IMongoQueryable<AuditLog>>().OrderBy(x => x.ExecutionTime).ToListAsync();
var auditLogs = await GetMongoQueryable()
.Where(x => x.EntityChanges.Any(y => y.EntityId == entityId && y.EntityTypeFullName == entityTypeFullName))
.As<IMongoQueryable<AuditLog>>()
.OrderByDescending(x => x.ExecutionTime)
.ToListAsync();
var entityChanges = auditLogs.SelectMany(x => x.EntityChanges).ToList();

2
modules/audit-logging/test/Volo.Abp.AuditLogging.TestBase/Volo/Abp/AuditLogging/AuditLogRepository_Tests.cs

@ -984,7 +984,7 @@ namespace Volo.Abp.AuditLogging
await AuditLogRepository.GetEntityChangeWithUsernameAsync(entityChanges.First().Id);
entityHistory.EntityChange.ChangeTime.ShouldBe(entityChanges.First().ChangeTime);
entityHistory.UserName.ShouldNotBeNull();;
entityHistory.UserName.ShouldNotBeNull();
}
}
}

Loading…
Cancel
Save