C#获取List<dynamic>动态实体值

当我们需要遍历动态一个实体想要知道某个字段有没有值时,我们可以这样来写

复制代码
            List<dynamic> result = conn.Query($"select * from 表 where id='123'").ToList();
            foreach (KeyValuePair<string, object> col in result[0])
            {
                string aa = col.Key;//属性
                string bb = col.Value.ToString();//值
                if (!string.IsNullOrWhiteSpace(col.Value.ToString()))
                {

                }
            }
posted @ 2022-08-09 16:25  雄~  阅读(2036)  评论(0)    收藏  举报