Правка по результатам тестирования

This commit is contained in:
Olga Nemt 2024-12-06 17:06:16 +05:00
parent e826a386d2
commit f647afcd53
2 changed files with 8 additions and 4 deletions

View File

@ -10,7 +10,7 @@ namespace Persistence.Repository;
/// </summary> /// </summary>
public static class QueryBuilders public static class QueryBuilders
{ {
public static void Apply<TEntity>(this IQueryable<TEntity> query, SectionPartRequest request) public static IQueryable<TEntity> Apply<TEntity>(this IQueryable<TEntity> query, SectionPartRequest request)
where TEntity : class, IWithSectionPart where TEntity : class, IWithSectionPart
{ {
if (request.IdSection.HasValue) if (request.IdSection.HasValue)
@ -25,9 +25,11 @@ public static class QueryBuilders
{ {
query = query.Where(e => e.DepthEnd <= request.DepthEnd); query = query.Where(e => e.DepthEnd <= request.DepthEnd);
} }
return query;
} }
public static void Apply<TEntity>(this IQueryable<TEntity> query,DateTimeOffset momentUtc) public static IQueryable<TEntity> Apply<TEntity>(this IQueryable<TEntity> query,DateTimeOffset momentUtc)
where TEntity : class, IChangeLog where TEntity : class, IChangeLog
{ {
momentUtc = momentUtc.ToUniversalTime(); momentUtc = momentUtc.ToUniversalTime();
@ -35,6 +37,8 @@ public static class QueryBuilders
query = query query = query
.Where(e => e.Creation <= momentUtc) .Where(e => e.Creation <= momentUtc)
.Where(e => e.Obsolete == null || e.Obsolete >= momentUtc); .Where(e => e.Obsolete == null || e.Obsolete >= momentUtc);
return query;
} }

View File

@ -139,8 +139,8 @@ public class ChangeLogRepository : IChangeLogRepository
CancellationToken token) CancellationToken token)
{ {
var query = CreateQuery(idDiscriminator); var query = CreateQuery(idDiscriminator);
query.Apply(momentUtc); query = query.Apply(momentUtc);
query.Apply(filterRequest); query = query.Apply(filterRequest);
var result = await query.ApplyPagination(paginationRequest, Convert, token); var result = await query.ApplyPagination(paginationRequest, Convert, token);