本文介绍了如何将ExpandoObject的字典设置为不区分大小写?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
给出以下代码
dynamic e = new ExpandoObject();
var d = e as IDictionary<string, object>;
for (int i = 0; i < rdr.FieldCount; i++)
d.Add(rdr.GetName(i), DBNull.Value.Equals(rdr[i]) ? null : rdr[i]);
有没有办法使其不区分大小写,因为给定字段名称employee_name
Is there a way to make it case insensitive so given the field name employee_name
e.Employee_name的工作原理与e.employee_name一样,
e.Employee_name works just as well as e.employee_name
似乎没有一个明显的方法,也许是一个黑客?
there doesn't seem to be an obvious way, perhaps a hack ?
推荐答案
您可以结帐执行是不区分大小写的动态对象。
You may checkout Massive's implementation of a MassiveExpando
which is case insensitive dynamic object.
这篇关于如何将ExpandoObject的字典设置为不区分大小写?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!