c# - LINQ IQueryable returning same rows with skip and take -
using mvc entity framework i'm calling function ajax passes in skip , take parameters.
[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) t : contententity { source.where(m => m.ispublished ).orderbydescending(m => m.datepublished).skip(skip).take(take) }
my issue every time call function same rows returned though debug , skip value increments, , have 100s of rows fetch from.
the solution add order clause suggested damien_the_unbeliever
Comments
Post a Comment