今天系统进行了单元测试发现一个bug,不知道怎么回事。我们整个小组花费了半天时间终于找到了问题所在,就是:DataSet case sensitive
原以为在DataSet.Tables.Add(new DataTable(string strTableName))时,是可以随便的,没有想到就是这个东西发生了问题。google 了一下,发现这篇文章:
http://blogs.msdn.com/smartclientdata/archive/2005/10/07/478087.aspx ( English )
突然大梦清醒,原来Dataset 也是 case sensitive (大小写敏感)的。查询MSDN 中关于 Dataset 的说明,有这么一段:
http://msdn2.microsoft.com/en-us/library/system.data.dataset.aspx
Whereas DataTable objects contain the data, the DataRelationCollection allows you to navigate though the table hierarchy. The tables are contained in a DataTableCollection accessed through the Tables property. When accessing DataTable objects, note that they are conditionally case sensitive. For example, if one DataTable is named "mydatatable" and another is named "Mydatatable", a string used to search for one of the tables is regarded as case sensitive. However, if "mydatatable" exists and "Mydatatable" does not, the search string is regarded as case insensitive. For more information about working with DataTable objects, see Creating a DataTable.
其它的先不管了,我就看到了对case sensitive 的描述:
如果 DataSet 中包含名为 "mydatatable" 和另一个 "Mydatatable"时,在使用表查询时,Dataset 是大小写敏感的,如果只包含一个 "mydatatable" ,则又不是大小写敏感的。
看到这里,才发现原来是对DataSet 的标操作时出现了问题。更改后一切ok。