使用 MVC 实体框架,我使用 AJAX 调用一个函数,该函数传入跳过并获取参数。
[HttpGet]
public async Task<ActionResult> _ViewMore( int take, int skip)
{
var c = await GetContent( take, skip);
return View(c)
}
public async Task<List<PartialContent>> GetContentForCulture(int take, int skip)
{
return await ContextHelper.SearchContent(take, skip);
}
public static async Task<List<PartialContent>> SearchContent( int take, int skip)
{
try
{
using (var context = new Context())
{
var content = context.ContentEntities.SearchContent(take, skip);
var f = await content.Select(s => new PartialContent
{
Subtype = s.Subtype,
Id = s.Id,
MainImage = s.MainImage,
}).ToListAsync();
return f;
}
}
catch (Exception ex)
{
// Log.Err(ex.Message, ex);
return null;
}
}
public static IQueryable<T> SearchContent<T>(this IQueryable<T> source, int take, int skip)
where T : ContentEntity
{
source.Where(m => m.IsPublished ).OrderByDescending(m => m.DatePublished).Skip(skip).Take(take)
}
我的问题是,每次我调用该函数时,都会返回相同的行,即使我进行了调试并且跳过值增加了,并且我有 100 行可以从中获取。