Custodio
Custodio

Reputation: 8934

Exist some kind of Ordering object in .NET

I developing a paged service to retrieve data from database using NHibernate. In my actual point I'm receiving a skip, take and string order parameter.

My question is, exist some native library to ordering in .NET, something that consider asc or desc ordering, maybe the list of field to order in priority.

e.g: Order Name Asc, City Desc.

So:
Paul | New York
Paul | Amsterdam

-- Edit

IEnumerable<Obj> actuals = _repository.LoadByName("Pa", p => p.Name);

And the method signature:

public IEnumerable<Obj> LoadByName<TKey> (string name, Func<Obj, TKey> ordering = null, int skip = 0, int take = 0) {

Upvotes: 0

Views: 81

Answers (2)

moi_meme
moi_meme

Reputation: 9318

LINQ --> OrderBy, ThenByDescending

Upvotes: 2

TheSean
TheSean

Reputation: 4566

List<T> has a Sort Method.

Upvotes: 0

Related Questions