The column name: id productName Num
Contents: 1 book1 sn25124
2 book2 sn554124
Now want to is controlled by the client, just select the id/productName after two fields, how to use linq query the records into such as follows:
Id productName
1 book1
2 book2
Var listOther=List. Select (x=& gt; ????? )
thank you
CodePudding user response:
Since to dynamically allocated key, use Dictionaryvar _keys=new List{" id ", "productName}";
DictionaryDic=new Dictionary (a);
_keys. ForEach (k=& gt;
{
Dic [k]=x.G etType () GetProperty (k). The GetValue (x);
});
Return dic.
CodePudding user response:
Is there a written linq?