سلام خدمت استاد مدائنی عزیز و همه همراهان عزیز
با عرض پوزش من یکم دیر دوره رو شروع کردم تازه امروز رسیدم به جلسه 50 برای نمایش پیجینگ یه مشکلی دارم اونم اینه که عملیات پیجینگ برای من اتفاق میوفته یعنی وقتی takentity رو روی 1 میذارم برام به صورت دستی با آدس جابجا میشه ولی تو نمایش زیر جدول برام فقط همون صفحه رو نمایش میده هیچ کلیدی دیگه ایی نمیسازه انگار حلقه فور اصلا کار نمیکنه ممنون میشم که راهنمایی کنید در زیر هم تصاویر کدم رو قرار دادم
سلام وقت بخیر
لطفا این کد رو جایگزین BasePaging خودتون کنید
namespace ShopStock.Domain.ViewModels.Common
{
public class BasePaging<T>
{
public BasePaging()
{
PageId = 1;
TakeEntity = 8;
HowManyPageAfterAndBefore = 2;
Entities = new List<T>();
}
public int PageId { get; set; }
public int PageCount { get; set; }
public int AllEntitiesCount { get; set; }
public int StartPage { get; set; }
public int EndPage { get; set; }
public int TakeEntity { get; set; }
public int SkipEntity { get; set; }
public int HowManyPageAfterAndBefore { get; set; }
public List<T> Entities { get; set; }
public async Task<BasePaging<T>> Paging(IQueryable<T> query)
{
var allEntitiesCount = query.Count();
var pageCount = (int)Math.Ceiling(allEntitiesCount / (double)TakeEntity);
PageId = pageCount < 1 ? PageId : PageId > pageCount ? pageCount : PageId;
AllEntitiesCount = allEntitiesCount;
SkipEntity= (PageId - 1) * TakeEntity;
PageCount = pageCount;
StartPage = PageId - HowManyPageAfterAndBefore <= 0 ? 1 : PageId - HowManyPageAfterAndBefore;
EndPage = PageId + HowManyPageAfterAndBefore > PageCount ? PageCount : PageId + HowManyPageAfterAndBefore;
Entities = query.Skip(SkipEntity).Take(TakeEntity).ToList();
return this;
}
public PagingViewModel GetCurrentPaging()
{
return new PagingViewModel()
{
PageId = this.PageId,
StartPage = this.StartPage,
EndPage = this.EndPage
};
}
}
public class PagingViewModel
{
public int PageId { get; set; }
public int StartPage { get; set; }
public int EndPage { get; set; }
}
}
ممنون از جناب موسوی
تشکر فراوان از دوست عزیز جناب آقای موسوی