How do I reference a field in Linq based on a dynamic fieldname

后端 未结 5 1315
予麋鹿
予麋鹿 2021-01-05 08:22

Firstly, apologies for the bad question title - not entirely sure if I am asking the correct thing.

Normally I can do the following to access a field:



        
5条回答
  •  有刺的猬
    2021-01-05 08:40

    You need to use reflection, like this: (Untested)

    somevalue = typeof(MyTable).GetProperty(fieldName).GetValue(table, null);
    

提交回复
热议问题