Optimized one lookup in search api and added maxRecords to API

This commit is contained in:
Joseph Milazzo 2022-11-10 09:04:14 -06:00
parent 5abc0fefd6
commit 50273db00c
5 changed files with 48 additions and 20 deletions

View file

@ -110,4 +110,21 @@ public static class QueryableExtensions
})
.SingleAsync();
}
/// <summary>
/// Only applies the Take if it's greater than 0
/// </summary>
/// <param name="queryable"></param>
/// <param name="takeAmt"></param>
/// <typeparam name="T"></typeparam>
/// <returns></returns>
public static IQueryable<T> TakeIfGreaterThan0<T>(this IQueryable<T> queryable, int takeAmt)
{
if (takeAmt > 0)
{
return queryable.Take(takeAmt);
}
return queryable;
}
}