score:0

change it into an iorderedqueryable<t> by calling .orderby() before skip and take. i think it's currently retrieving all rows from the table. normally i'd have expected an exception to be thrown but i'm not sure why it's not been - are you using the results? have you tried running it with a page > 0?

try this:

var results;

if (facilityid != guid.empty)
{
    results = context.calllists.where(c => c.agencyid == agencyid).orderby(c => c.something);
}
else
{
    results = context.calllists.where(c => c.agencyid == agencyid && c.initiatedfacilityid == facilityid).orderby(c => c.something);
}

if (request.page > 0)
{
    results = results.skip((request.page - 1) * request.pagesize);
}

return results.take(request.pagesize);

in addition to this, you need to come up with a way of handling the sql azure transient errors. this is basically a subset of errors that can be thrown when executing queries in sql azure, which should be handled by waiting and retrying the operation, usually with increasing wait times between retries until you finally accept a failure. read more about it here and here.


Related Query

More Query from same tag