You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
20 lines
648 B
20 lines
648 B
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Linq.Expressions;
|
|
|
|
namespace Infrastructure.Extensions
|
|
{
|
|
public static class QueryableExtensions
|
|
{
|
|
public static IQueryable<TSource> WhereIf<TSource>(this IQueryable<TSource> source, bool condition, Expression<Func<TSource, bool>> predicate)
|
|
{
|
|
return condition ? source.Where(predicate) : source;
|
|
}
|
|
|
|
public static List<TSource> Paged<TSource>(this IQueryable<TSource> source, int pageIndex, int pageSize)
|
|
{
|
|
return source.Skip(pageSize * (pageIndex - 1)).Take(pageSize).ToList();
|
|
}
|
|
}
|
|
} |