Skip to content

Commit

Permalink
Renamed default pagination to Empty.
Browse files Browse the repository at this point in the history
  • Loading branch information
fiseni committed Sep 22, 2024
1 parent 3d77925 commit 0bfd7b7
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
<Description>EntityFrameworkCore plugin to Pozitron.QuerySpecification containing EF evaluators.</Description>
<Summary>EntityFrameworkCore plugin to Pozitron.QuerySpecification containing EF evaluators.</Summary>

<Version>10.0.0</Version>
<PackageTags>pozitron query specification efcore</PackageTags>
<Version>10.1.0</Version>
<PackageTags>fiseni pozitron query specification efcore</PackageTags>
<PackageReleaseNotes>
- Dropped support for old TFMs. Support only .NET 8.
- Dropped support for old plugin packages. Support only EntityFrameworkCore 8.
Expand Down
7 changes: 3 additions & 4 deletions src/QuerySpecification.EntityFrameworkCore/RepositoryBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,12 @@ public virtual async Task<int> SaveChangesAsync(CancellationToken cancellationTo
public virtual async Task<T> FirstAsync(Specification<T> specification, CancellationToken cancellationToken = default)
{
var result = await ApplySpecification(specification).FirstOrDefaultAsync(cancellationToken);
return result is null ? throw new EntityNotFoundException(typeof(T).Name) : result;
return result ?? throw new EntityNotFoundException(typeof(T).Name);
}
public virtual async Task<TResult> FirstAsync<TResult>(Specification<T, TResult> specification, CancellationToken cancellationToken = default)
{
var result = await ApplySpecification(specification).FirstOrDefaultAsync(cancellationToken);
return result is null ? throw new EntityNotFoundException(typeof(T).Name) : result;
return result ?? throw new EntityNotFoundException(typeof(T).Name);
}
public virtual async Task<T?> FirstOrDefaultAsync(Specification<T> specification, CancellationToken cancellationToken = default)
{
Expand Down Expand Up @@ -145,7 +145,7 @@ public virtual async Task<TResult> ProjectToFirstAsync<TResult>(Specification<T>

var result = await projectedQuery.FirstOrDefaultAsync(cancellationToken);

return result is null ? throw new EntityNotFoundException(typeof(T).Name) : result;
return result ?? throw new EntityNotFoundException(typeof(T).Name);
}
public virtual async Task<TResult?> ProjectToFirstOrDefaultAsync<TResult>(Specification<T> specification, CancellationToken cancellationToken = default)
{
Expand Down Expand Up @@ -231,4 +231,3 @@ private ref struct SpecPaging(int skip, int take)
public int Take = take;
}
}

2 changes: 1 addition & 1 deletion src/QuerySpecification/Paging/Pagination.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public Pagination(int totalItems, int totalPages, int pageSize, int page, int st
HasNext = hasNext;
}

public static Pagination Default { get; } = new Pagination(PaginationSettings.Default, 0, null, null);
public static Pagination Empty { get; } = new Pagination(PaginationSettings.Default, 0, null, null);

public Pagination(int itemsCount, PagingFilter filter)
: this(PaginationSettings.Default, itemsCount, filter.PageSize, filter.Page)
Expand Down
4 changes: 2 additions & 2 deletions src/QuerySpecification/QuerySpecification.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
<Description>Abstract package for building query specifications.</Description>
<Summary>Abstract package for building query specifications.</Summary>

<Version>10.0.0</Version>
<PackageTags>pozitron query specification</PackageTags>
<Version>10.1.0</Version>
<PackageTags>fiseni pozitron query specification</PackageTags>
<PackageReleaseNotes>
- Dropped support for old TFMs. Support only .NET 8.
- Dropped support for old plugin packages. Support only EntityFrameworkCore 8.
Expand Down
4 changes: 2 additions & 2 deletions tests/QuerySpecification.Tests/Paging/PaginationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,9 @@ public void CalculatesValues_GivenJsonConstructor(int totalItems, int totalPages
}

[Fact]
public void DefaultPagination_SetsDefaultValues()
public void EmptyPagination_SetsDefaultValues()
{
var pagination = Pagination.Default;
var pagination = Pagination.Empty;
var pageSize = PaginationSettings.Default.DefaultPageSize;
AssertPaginationValues(pagination, new Expected(0, 1, pageSize, 1, 0, 0, false, false, pageSize, 0));
}
Expand Down

0 comments on commit 0bfd7b7

Please sign in to comment.