If you want to create an anonymous object from another in c#, you can use the handy Linq method select
:
var myList = new List<MyClass>();
myList.Add(new MyClass(valueA, valueB, valueC));
myList.Add(new MyClass(valueA, valueB, valueC));
var myResult = myList.select(l => new { l.PropA, l.PropB });
I wonder, if there is a built-in method, some class or a NuGet package that allows you to do the same from a list of strings. I imagine something like:
myResult = myList.select("PropA", "PropB");
// or
myResult = myList.select(myPropertyEnumerableOfString);
Is there something built-in, or do I need to iterate over my property list using reflections?