Call a custom method in linq query

Viewed 579

I need to call a custom method in linq query, e.g.:

IQueryable<Person> query = _db.Persons.OrderBy(p => Decrypt(p.Name));

However, in this case Decrypt gives me an exception.

I also tried with this approach:

IQueryable<Person> query = _db.Persons.AsEnumerable()
                                      .OrderBy(p => Decrypt(p.Name))
                                      .AsQueryable<Person>();

However in this case it works but as I'm using this query as a source (SelectMethod) for my ListView, paging is not working when using DataPager control.

3 Answers
Related