mardi 22 septembre 2015

Use property Created by Property Info and use in Lmabda

I have a method with parameter as object, the object is a string value of properties in DocumentModel Class

 private PropertyInfo SortingListView(object obj)
 {
     return typeof(DocumentModel).GetProperty(obj.ToString());
 }

I want the PropertyInfo to be used in a lambda expression like below,

 var SortedDocuments=Documents.OrderByDescending(x => SortingListView(obj));

But its not working. Any suggestions ? or any better way ? please help.





Aucun commentaire:

Enregistrer un commentaire