关于SqlDataReader的Item[String]

来源:互联网 发布:在淘宝网上开店赚钱吗 编辑:程序博客网 时间:2024/05/16 05:39

在我们日常项目中使用SqlDataReader的Item属性进行如下的数据读入时,常常有程序员因为数据库是case-insensitive的,所以往往把EmployeeID写成employeeid,或者其他不注意大小写的情况。

int aInt=(int)reader["EmployeeID"] ;

今天偶然看到IDataRecord这个接口,其Item[String]的定义中有这么一段话:

A case-sensitive lookup is performed first. If it fails, a second case-insensitive search is made.

而SqlDataReader是实现了IDataRecord的,所以如果使用Item属性时不注意大小写,会造成效率的降低。

原创粉丝点击