/// <summary> /// Adds where clause to the <see cref="IQueryable{T}"/> based on the passed <paramref name="criteria"/>. /// </summary> /// <typeparam name="TEntity">The type used in the <see cref="IQueryable{T}"/>.</typeparam> /// <param name="source">The <see cref="IQueryable{T}"/>.</param> /// <param name="criteria">The <see cref="ICriteria"/>.</param> /// <returns>The <see cref="IQueryable{T}"/>.</returns> public static IQueryable <TEntity> Where <TEntity>(this IQueryable <TEntity> source, ICriteria criteria) where TEntity : class, IEntity { if (source == null) { throw new ArgumentNullException(nameof(source)); } if (criteria == null) { throw new ArgumentNullException(nameof(criteria)); } var filter = criteria.GetExpression <TEntity>(); var expression = new FilterBuilder().GetExpression <TEntity>(filter); return(source.Where(expression)); }