/// <summary> /// applies a standard list filter to a load operation /// </summary> /// <typeparam name="T">type of entities to load</typeparam> /// <param name="operation">operation to modify</param> /// <param name="filter">filter to apply</param> /// <returns>load operation for fluent behavior</returns> public static LoadOperation <T> ApplyFilter <T>(this LoadOperation <T> operation, ListFilter filter) { if (!filter.Count.HasValue || filter.Count > 500) { filter.Count = 500; } if (filter.Count <= 0) { throw new ArgumentException($"A count of '{filter.Count}' makes no sense", nameof(filter.Count)); } operation.Limit(filter.Count.Value); if (filter.Continue.HasValue) { operation.Offset(filter.Continue.Value); } if (!string.IsNullOrEmpty(filter.Sort)) { operation.OrderBy(new OrderByCriteria(Field.Property <T>(filter.Sort, true), !filter.Descending)); } return(operation); }