I am facing one issue with linq query in c# , my linq query as per below
list = (from row in dt.AsEnumerable()
select new Perfmon
{
id = row.Field<long>("id"),
counter1 = row.Field<string>("counter"),
}).ToList();
I have one perfmon class and it contains properties like (id, counter1, counter2 ...) there are more then 20 counters now i have developed sql query to select id and counter based on passed countername in parameter e.g. if i have passed counter1 then it will select id , counter1 (renamed as counter) only
if i will use switch case here then it will have 20 witch case, can anyone please help me how can bind property dynamically in linq?
Thanks in advance.