Esempio n. 1
0
        void DoLoadDataSet(IDbCommand command, DataSet dataSet, string[] tableNames)
        {
            CheckUtil.ArgumentNotNullOrEmptyForCollection(tableNames, "tableNames");

            for (int i = 0; i < tableNames.Length; i++)
            {
                CheckUtil.ArgumentNotNullOrEmpty(tableNames[i], string.Concat("tableNames[", i, "]"));
                //if (string.IsNullOrEmpty(tableNames[i])) throw new ArgumentException("值不能为空或者空字符串", string.Concat("tableNames[", i, "]"));
            }

            try
            {
                using (DbDataAdapter adapter = GetDataAdapter(UpdateBehavior.Standard))
                {
                    ((IDbDataAdapter)adapter).SelectCommand = command;

                    //DateTime startTime = DateTime.Now;
                    string systemCreatedTableNameRoot = "Table";
                    for (int i = 0; i < tableNames.Length; i++)
                    {
                        string systemCreatedTableName = (i == 0) ? systemCreatedTableNameRoot : systemCreatedTableNameRoot + i;

                        adapter.TableMappings.Add(systemCreatedTableName, tableNames[i]);
                    }

                    adapter.Fill(dataSet);
                    //instrumentationProvider.FireCommandExecutedEvent(startTime);
                }
            }
            catch (Exception e)
            {
                //instrumentationProvider.FireCommandFailedEvent(command.CommandText, ConnectionStringNoCredentials, e);
                throw;
            }
        }