Can I take object property in Linq from string input?
For an example I have collection of clothes:
clothes.OrderBy(x => x.Name);
This will order them by Name, ok.
But user should can order them by also Price
, Type
, Creation Date
and so on.
So is it possible to do something like:
clothes.OrderBy(x => x + "." + inputFilter);
Well this is obviously not working like this, but OrderBy
doesn't have much methods either.
My idea is to skip some Switch Case construction, if there is some smarter way. Is it such way is my question?
(I`m using asp.net MVC with Razor engine.)