-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
61 additions
and
25 deletions.
There are no files selected for viewing
22 changes: 22 additions & 0 deletions
22
VPMReposSynchronizer.Core/Extensions/EnumerableExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
using Microsoft.EntityFrameworkCore; | ||
using VPMReposSynchronizer.Core.Models.Types; | ||
|
||
namespace VPMReposSynchronizer.Core.Extensions; | ||
|
||
public static class EnumerableExtensions | ||
{ | ||
public static PageResult<TSource> ToPageResult<TSource>(this IEnumerable<TSource> source, int page, int pageSize) | ||
{ | ||
var items = source.Skip(page * pageSize).Take(pageSize).ToArray(); | ||
|
||
return new PageResult<TSource>(items, source.Count()); | ||
} | ||
|
||
public static async ValueTask<PageResult<TSource>> ToPageResultAsync<TSource>(this IQueryable<TSource> source, | ||
int page, int pageSize) | ||
{ | ||
var items = await source.Skip(page * pageSize).Take(pageSize).ToArrayAsync(); | ||
|
||
return new PageResult<TSource>(items, source.Count()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
namespace VPMReposSynchronizer.Core.Models.Types; | ||
|
||
public record PageResult<T>(IEnumerable<T> Items, int TotalCount); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters