Guest User

Untitled

a guest
Apr 21st, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. query = query.OrderBy(x => x."ProductId");
  2.  
  3. System.Reflection.PropertyInfo prop = typeof(YourType).GetProperty("PropertyName");
  4.  
  5. query = query.OrderBy(x => prop.GetValue(x, null));
  6.  
  7. PropertyDescriptor prop = TypeDescriptor.GetProperties(typeof(YourType)).Find("PropertyName");
  8.  
  9. query = query.OrderBy(x => prop.GetValue(x));
  10.  
  11. query = query.OrderBy(x => x.GetType().GetProperty("ProductId").GetValue(x, null));
  12.  
  13. typeof(YourType).GetProperty("ProductId").GetValue(theInstance);
  14.  
  15. query = query.OrderBy(x => x.GetType().GetProperty("ProductId").GetValue(x, null));
  16.  
  17. if (sortBy == "ProductId")
  18. query.OrderBy(x => x.ProductId);
  19. else
  20. query.OrderBy(x => x.ProductName);
Add Comment
Please, Sign In to add comment