Added database loading logic
This commit is contained in:
15
src/HopFrame.Core/Services/Implementations/TableManager.cs
Normal file
15
src/HopFrame.Core/Services/Implementations/TableManager.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace HopFrame.Core.Services.Implementations;
|
||||
|
||||
internal sealed class TableManager<TModel>(DbContext context) : ITableManager where TModel : class {
|
||||
|
||||
public async Task<IEnumerable<object>> LoadPage(int page, int perPage = 25) {
|
||||
var table = context.Set<TModel>();
|
||||
return await table
|
||||
.Skip(page * perPage)
|
||||
.Take(perPage)
|
||||
.ToArrayAsync();
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user