Search code examples
linqgenerics.net-corerepositoryiorderedqueryable

how can i pass parameter for Func<IQueryable<T>, IOrderedQueryable<T>> orderBy = null,


I have the following generic repository function but am unable to pass a parameter for order by

Task<List<T>> AdvGetAllAsync(
            Expression<Func<T, bool>> expression = null,
            Func<IQueryable<T>, IOrderedQueryable<T>> orderBy = null,
            List<string> includes = null
            );

Solution

  • Probably in this way:

    var result = await someRep.AdvGetAllAsync(orderBy: q => q.OrderBy(x => x.SomeField));