0

I have an issue when ordering an IQueryable. I want to navigate through a property when sorting my list. This is because the property i am trying to orrder by is located within another object. The order property is MyIdentifier and this identifier is located in MyObject in Mymodel

public Models.MyModel GetList(Models.MyModel search, int pageNumber, int pageSize, string sortOrder, string sortColumn)
        {
                var list = Get(search, currentUser, repository1));

                Models.MyModel result = new Models.MyModel();
                result.TotalRows = q.Count();
                result.GridData = q.OrderBy(sortColumn, sortOrder).Skip(pageNumber).Take(pageSize).ToList();                      
                return result;            
    }

The issue here is i am passing MyIdentifier in the sortColumn as a string. By what i need to do here is navigate through MyObject end then pass MyIdentifier as sortColumn. like so: MyObject.MyIdentifier. But this does not work. What is the best solution for this?

thanks.

Lahib
  • 1,196
  • 5
  • 29
  • 60
  • You are using non standard `OrderBy` method. Where it comes from and what's inside, i.e. can we see the implementation? – Ivan Stoev Jan 24 '17 at 10:25
  • Possible duplicate of [Dynamic LINQ OrderBy on IEnumerable](http://stackoverflow.com/questions/41244/dynamic-linq-orderby-on-ienumerablet) – Peter B Jan 24 '17 at 10:28

0 Answers0