/// <summary> /// Creates a new <see cref="IEntitySorter{TEntity}" /> that sorts a collection of /// <typeparamref name="TEntity" /> objects in descending order by using the property, specified by it's /// <paramref name="propertyName" />. /// </summary> /// <param name="propertyName"> /// Name of the property or a list of chained properties, separated by a dot. /// </param> /// <returns> /// A new <see cref="IEntitySorter{TEntity}" />. /// </returns> /// <exception cref="ArgumentException"> /// Thrown when the specified <paramref name="propertyName" /> is /// empty or when the specified property could not be found on the <typeparamref name="TEntity" />. /// </exception> /// <exception cref="ArgumentNullException"> /// Thrown when <paramref name="propertyName" /> is null. /// </exception> public static IEntitySorter <TEntity> OrderByDescending(string propertyName) { var builder = new EntitySorterBuilder <TEntity>(propertyName) { SortDirection = SortDirection.Descending }; return(builder.BuildOrderByEntitySorter()); }
/// <summary> /// Creates a new <see cref="IEntitySorter{TEntity}" /> that performs a subsequent ordering of the /// elements in in a collection of <typeparamref name="TEntity" /> objects in ascending order /// by using the property, specified by it's <paramref name="propertyName" />. /// </summary> /// <typeparam name="TEntity"> /// The type of the entity. /// </typeparam> /// <param name="sorter"> /// The sorter. /// </param> /// <param name="propertyName"> /// Name of the property or a list of chained properties, separated by a dot. /// </param> /// <returns> /// A new <see cref="IEntitySorter{TEntity}" />. /// </returns> /// <exception cref="ArgumentNullException"> /// Thrown when the specified <paramref name="propertyName" /> /// is a null reference. /// </exception> /// <exception cref="ArgumentException"> /// Thrown when the specified <paramref name="propertyName" /> is /// empty or when the specified property could not be found on the <typeparamref name="TEntity" />. /// </exception> /// <exception cref="ArgumentNullException"> /// Thrown when <paramref name="sorter" /> or /// <paramref name="propertyName" /> are null. /// </exception> public static IEntitySorter <TEntity> ThenBy <TEntity>(this IEntitySorter <TEntity> sorter, string propertyName) { if (sorter == null) { throw new ArgumentNullException("sorter"); } var builder = new EntitySorterBuilder <TEntity>(propertyName) { SortDirection = SortDirection.Ascending }; return(builder.BuildThenByEntitySorter(sorter)); }