I am stuck at the following problem:
I have a class like
public class DataItem
{
public decimal? ValueA{ get; set; }
public decimal? ValueB { get; set; }
public decimal? valueC { get; set; }
...
}
and would like to have something like
var keySelectors = new Dictionary<string, Func<DataItem, decimal?>>
{
{"ValueA", x => x.ValueA},
{"ValueB", x => x.ValueB},
{"ValueC", x => x.ValueC},
...
}.ToList();
to be used for a user defined analysis, but I need a more generic way to create it.
So I tried the following:
var keySelectors= typeof(DataItem).GetProperties()
.Select(x => new KeyValuePair<string, Func<DataItem, decimal?>>(x.Name, x.DoNotKnow));
the DoNotKnow is the point where I am lost.
Or is this a wrong approach for the desired result to enable the user to choose the data on which his analysis is based?