Create readme.txt (#33265)
* Create readme.txt * Delete aspnetcore/data/ef-rp/intro/samples/cu80 directorypull/33255/head
parent
f14939ae22
commit
36b11ec0a6
|
@ -1,36 +0,0 @@
|
||||||
// See https://github.com/dotnet/AspNetCore.Docs/pull/28082
|
|
||||||
// This code has been proposed but has not be tested.
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
|
||||||
|
|
||||||
namespace ContosoUniversity
|
|
||||||
{
|
|
||||||
public class PaginatedList<T> : List<T>
|
|
||||||
{
|
|
||||||
public PaginatedList(IEnumerable<T> items, int count, int pageIndex, int pageSize = 20)
|
|
||||||
{
|
|
||||||
PageIndex = pageIndex;
|
|
||||||
TotalPages = (int)Math.Ceiling(count / (double)pageSize);
|
|
||||||
|
|
||||||
this.AddRange(items);
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool HasPreviousPage => PageIndex > 1;
|
|
||||||
public bool HasNextPage => PageIndex < TotalPages;
|
|
||||||
public int PageIndex { get; private set; }
|
|
||||||
public int TotalPages { get; private set; }
|
|
||||||
|
|
||||||
public static async Task<PaginatedList<T>> CreateAsync(
|
|
||||||
IQueryable<T> source, int pageIndex, int pageSize = 20)
|
|
||||||
{
|
|
||||||
var count = await source.CountAsync();
|
|
||||||
var items = await source.Skip(
|
|
||||||
(pageIndex - 1) * pageSize)
|
|
||||||
.Take(pageSize).ToListAsync();
|
|
||||||
return new PaginatedList<T>(items, count, pageIndex, pageSize);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,13 +0,0 @@
|
||||||
{
|
|
||||||
"DetailedErrors": true,
|
|
||||||
"Logging": {
|
|
||||||
"LogLevel": {
|
|
||||||
"Default": "Information",
|
|
||||||
"Microsoft.AspNetCore": "Warning"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"ConnectionStrings": {
|
|
||||||
"SchoolContextSQLite": "Data Source=CU.db"
|
|
||||||
},
|
|
||||||
"MyMaxModelBindingCollectionSize": "3"
|
|
||||||
}
|
|
|
@ -0,0 +1 @@
|
||||||
|
Delete this readme file when the code has been updated to .NET 9
|
Loading…
Reference in New Issue