I would like to be able to pass in a Func<T, ?> that allows me to choose exactly how to sort a list of items... the issue I have is the the return type might vary... so for example I want to do something like this (not production code):
Func<POline, string> poLineOrder
if (option) poLineOrder = poline => poline.PartNumber;
else poLineOrder = poline => poline.LineOrder;
var orderedLines = poLines.OrderBy(poLineOrder);
The issue here is that while PartNumber is a string, LineOrder is an int, and this code doesn't compile. I have a feeling I'm going to have to build an Expression (?) but I can't seem to get the syntax right.
(Yes, I can solve this, by using poline.LineOrder.ToString("D10") but I'm asking the more general question here... thanks!)
-mdb