Demo entry 6663294

mc_2

   

Submitted by mc_2 on Nov 29, 2017 at 21:25
Language: C#. Code size: 648 Bytes.

public virtual IEnumerable<T> FindBy<TKey>(Expression<Func<T, bool>> filterPredicate,
                                                   Expression<Func<T, TKey>> orderByPredicate = null,
                                                   OrderByDirection orderByDirection = OrderByDirection.Ascending)
{
    var baseQuery = _context.Set<T>().Where(filterPredicate);
    if (orderByPredicate != null)
    {
        return orderByDirection == OrderByDirection.Ascending
            ? baseQuery.OrderBy(orderByPredicate).ToList()
            : baseQuery.OrderByDescending(orderByPredicate).ToList();
    }
    return baseQuery.ToList();
}

This snippet took 0.00 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).