zoukankan      html  css  js  c++  java
  • 新发现:微软提供的SqlHelper中FillDataset方法一个小Bug (转)

    FillDataset(SqlConnection connection, CommandType commandType,
     string commandText, DataSet dataSet, string[] tableNames)
    当调用此方法,并指定映射表名数组,对应参数tableNames
    若元素超过3个,即指定表名超过3个时,从第3个表名开始返回的将是系统默认的表名
    而非用户指定的表名(如,指定"header" "detail" "relation",第3个返回了Table2)

    此Bug原因在这里:
    private static void FillDataset(SqlConnection connection, SqlTransaction transaction, CommandType commandType,
       string commandText, DataSet dataSet, string[] tableNames,
       params SqlParameter[] commandParameters)
    {
    ...
    string tableName = "Table";
         for (int index=0; index < tableNames.Length; index++)
         {
          if( tableNames[index] == null || tableNames[index].Length == 0 ) throw new ArgumentException( "The tableNames parameter must contain a list of tables, a value was provided as null or empty string.", "tableNames" );
          dataAdapter.TableMappings.Add(tableName, tableNames[index]);
     tableName += (index + 1).ToString(); //若超过3个表,则
         tableName会变成Table11,Table111,返回映射表名即为Table2,Table3了
         解决方法即在此句前面加“tableName = "Table";”即可
         }
    ...
    }


  • 相关阅读:
    EntityManager 实例化方法
    Java Jpa 规范
    Spring HandlerInterceptor
    Spring data jpa
    Spring Security @PreAuthorize 拦截无效
    Java ee el表达式
    脏读&幻读
    OR查询是否会使得索引失效?
    ThinkPHP中的parseDSN方法的坑记录一下
    js , map中的坑
  • 原文地址:https://www.cnblogs.com/onekey/p/42992.html
Copyright © 2011-2022 走看看