YourProducts.OrderByDescending(p => p.GetType().GetProperty(A.GetValue(c,null))
It will get your property value of Product class dynamically.
Here are some example to use lamda expression in C# 3.0:
x => x + 1 // Implicitly typed, expression body
x => { return x + 1; } // Implicitly typed, statement body
(int x) => x + 1 // Explicitly typed, expression body
(int x) => { return x + 1; } // Explicitly typed, statement body
(x, y) => x * y // Multiple parameters
() => Console.WriteLine() // No parameters
No comments:
Post a Comment