Fixes the calls to the member service paged queries to do a normal GetAll without parameters if the int.max value is used. Ensures that if too many id params are sent to GetAll an exception is raised

This commit is contained in:
Shannon
2014-09-08 19:04:28 +10:00
parent fd8cd4be99
commit 8fcd2200d0
2 changed files with 13 additions and 0 deletions

View File

@@ -604,6 +604,14 @@ namespace Umbraco.Core.Persistence.Repositories
Sql sql, int pageIndex, int pageSize, out int totalRecords,
Func<IEnumerable<TDto>, int[]> resolveIds)
{
//If a max size is passed in, just do a normal get all!
if (pageSize == int.MaxValue)
{
var result = GetAll().ToArray();
totalRecords = result.Count();
return result;
}
var pagedResult = Database.Page<TDto>(pageIndex + 1, pageSize, sql);
totalRecords = Convert.ToInt32(pagedResult.TotalItems);

View File

@@ -133,6 +133,11 @@ namespace Umbraco.Core.Persistence.Repositories
/// <returns></returns>
public IEnumerable<TEntity> GetAll(params TId[] ids)
{
if (ids.Length > 2000)
{
throw new InvalidOperationException("Cannot perform a query with more than 2000 parameters");
}
//ensure they are de-duplicated, easy win if people don't do this as this can cause many excess queries
ids = ids.Distinct()
//don't query by anything that is a default of T (like a zero)