System.Data.Common.DataTableMappingCollection.Add(string, string)

Here are the examples of the csharp api class System.Data.Common.DataTableMappingCollection.Add(string, string) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

20 Examples 7

1. Example

Project: referencesource
Source File: DataAdapter.cs
View license
private void CloneFrom(DataAdapter from) {
            _acceptChangesDuringUpdate = from._acceptChangesDuringUpdate;
            _acceptChangesDuringUpdateAfterInsert = from._acceptChangesDuringUpdateAfterInsert;
            _continueUpdateOnError = from._continueUpdateOnError;
            _returnProviderSpecificTypes = from._returnProviderSpecificTypes; // WebData 101795
            _acceptChangesDuringFill = from._acceptChangesDuringFill;
            _fillLoadOption = from._fillLoadOption;
            _missingMappingAction = from._missingMappingAction;
            _missingSchemaAction = from._missingSchemaAction;

            if ((null != from._tableMappings) && (0 < from.TableMappings.Count)) {
                DataTableMappingCollection parameters = this.TableMappings;
                foreach(object parameter in from.TableMappings) {
                    parameters.Add((parameter is ICloneable) ? ((ICloneable)parameter).Clone() : parameter);
                }
            }
        }

2. Example

View license
ITableMapping ITableMappingCollection.Add(string sourceTableName, string dataSetTableName) {
            return Add(sourceTableName, dataSetTableName);
        }

3. Example

Project: spring-net
Source File: AdoTemplate.cs
View license
protected virtual ITableMappingCollection DoCreateMappingCollection(string[] dataSetTableNames)
        {
            DataTableMappingCollection mappingCollection;

            if (dataSetTableNames == null)
            {
                dataSetTableNames = new string[] { "Table" };
            }
            foreach (string tableName in dataSetTableNames)
            {
                if (StringUtils.IsNullOrEmpty(tableName))
                {
                    throw new ArgumentException("TableName for DataTable mapping can not be null or empty");
                }
            }
            mappingCollection = new DataTableMappingCollection();
            int counter = 0;
            bool isFirstTable = true;
            foreach (string dataSetTableName in dataSetTableNames)
            {
                string sourceTableName;
                if (isFirstTable)
                {
                    sourceTableName = "Table";
                    isFirstTable = false;
                }
                else
                {
                    sourceTableName = "Table" + ++counter;
                }
                mappingCollection.Add(sourceTableName, dataSetTableName);
            }
            return mappingCollection;
        }

4. Example

Project: SubSonic-2.0
Source File: DataProvider.cs
View license
protected static void AddTableMappings(DataAdapter da, DataSet ds)
        {
            const string rootName = "Table";
            string[] tableNames = GetTableNames(ds);

            for(int i = 0; i < tableNames.Length; i++)
            {
                string newName = (i == 0) ? rootName : rootName + i;
                da.TableMappings.Add(newName, tableNames[i]);
            }
        }

5. Example

Project: Implem.CodeDefiner
Source File: SqlContainer.cs
View license
public SqlDataAdapter SqlDataAdapter(SqlCommand sqlCommand)
        {
            var sqlDataAdapter = new SqlDataAdapter(sqlCommand);
            var number = string.Empty;
            DataTableNames.Select((o, i) => new { TableName = o, Index = i }).ForEach(data =>
            {
                if (data.Index != 0) number = data.Index.ToString();
                sqlDataAdapter.TableMappings.Add("Table" + number, data.TableName);
            });
            return sqlDataAdapter;
        }

6. Example

Project: Implem.Pleasanter
Source File: SqlContainer.cs
View license
public SqlDataAdapter SqlDataAdapter(SqlCommand sqlCommand)
        {
            var sqlDataAdapter = new SqlDataAdapter(sqlCommand);
            var number = string.Empty;
            DataTableNames.Select((o, i) => new { TableName = o, Index = i }).ForEach(data =>
            {
                if (data.Index != 0) number = data.Index.ToString();
                sqlDataAdapter.TableMappings.Add("Table" + number, data.TableName);
            });
            return sqlDataAdapter;
        }

7. Example

View license
public void FillDataSetFromStatement(DataSet dataSet, string sqlCommandText, params SqlParameter[] sqlParameters)
        {
            if (dataSet == null)
            {
                throw new ArgumentNullException("dataSet");
            }

            if (sqlCommandText == null)
            {
                throw new ArgumentNullException("sqlCommandText");
            }

            using (SqlCommand sqlCommand = this.CreateStatementCommand(sqlCommandText, sqlParameters))
            {
                using (SqlDataAdapter sqlDataAdapter = new SqlDataAdapter(sqlCommand))
                {
                    for (int i = 0; i < dataSet.Tables.Count; i++)
                    {
                        if (i == 0)
                        {
                            sqlDataAdapter.TableMappings.Add("Table", dataSet.Tables[i].TableName);
                        }
                        else
                        {
                            sqlDataAdapter.TableMappings.Add(string.Format(CultureInfo.InvariantCulture, "Table{0}", i), dataSet.Tables[i].TableName);
                        }
                    }

                    sqlDataAdapter.Fill(dataSet);
                }
            }
        }

8. Example

View license
public void FillDataSetFromStoredProcedure(
           DataSet dataSet,
           string storedProcedureName,
           params SqlParameter[] sqlParameters)
        {
            if (dataSet == null)
            {
                throw new ArgumentNullException("dataSet");
            }

            if (storedProcedureName == null)
            {
                throw new ArgumentNullException("storedProcedureName");
            }

            using (SqlCommand sqlCommand = this.CreateStoredProcedureCommand(storedProcedureName, sqlParameters))
            {
                using (SqlDataAdapter sqlDataAdapter = new SqlDataAdapter(sqlCommand))
                {
                    for (int i = 0; i < dataSet.Tables.Count; i++)
                    {
                        if (i == 0)
                        {
                            sqlDataAdapter.TableMappings.Add("Table", dataSet.Tables[i].TableName);
                        }
                        else
                        {
                            sqlDataAdapter.TableMappings.Add(string.Format(CultureInfo.InvariantCulture, "Table{0}", i), dataSet.Tables[i].TableName);
                        }
                    }

                    sqlDataAdapter.Fill(dataSet);
                }
            }
        }

9. Example

Project: Kalman.Studio
Source File: Database.cs
View license
void DoLoadDataSet(IDbCommand command, DataSet dataSet, string[] tableNames)
        {
            C/n ..... /n //View Source file for more details /n }

10. Example

View license
[Test]
        public void DataSetFillNoParams()
        {
            String sql = "select USER_ID, USER_NAME from USER_TABLE";
            DataSet dataSet = new DataSet();
            adoOperations.DataSetFill(dataSet, CommandType.Text, sql);
            Assert.AreEqual(1, dataSet.Tables.Count);
            Assert.AreEqual(18, dataSet.Tables["Table"].Rows.Count);

            dataSet = new DataSet();
            adoOperations.DataSetFill(dataSet, CommandType.Text, sql, new string[] {"TestObjects"});
            Assert.AreEqual(1, dataSet.Tables.Count);
            Assert.AreEqual(18, dataSet.Tables["TestObjects"].Rows.Count);

            dataSet = new DataSet();
            DataTableMappingCollection mappingCollection =
                new DataTableMappingCollection();
            DataTableMapping testObjectsMapping = mappingCollection.Add("Table", "TestObjects");
            testObjectsMapping.ColumnMappings.Add("USER_ID", "UserID");
            testObjectsMapping.ColumnMappings.Add("USER_NAME", "UserName");
            adoOperations.DataSetFill(dataSet, CommandType.Text, sql, mappingCollection);
            Assert.AreEqual(1, dataSet.Tables.Count);
            Assert.AreEqual(18, dataSet.Tables["TestObjects"].Rows.Count);
            foreach (DataRow testObjectRow in dataSet.Tables["TestObjects"].Rows)
            {
                Assert.IsNotNull(testObjectRow["UserID"]);
                Assert.IsNotNull(testObjectRow["UserName"]);
            }
        }

11. Example

Project: Dos.ORM
Source File: Database.cs
View license
private void DoLoadDataSet(DbCommand command, DataSet dataSet, string[] tableNames)
        {
            Check.Require(tableNames != null && tableNames.Length > 0, "tableNames could not be null or empty.");
            Check.Require(dataSet != null, "dataSet could not be null.");

            using (DbDataAdapter adapter = GetDataAdapter())
            {
                WriteLog(command);

                ((IDbDataAdapter)adapter).SelectCommand = command;


                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);

            }
        }

12. Example

Project: Dos.ORM
Source File: Database.cs
View license
private void DoLoadDataSet(DbCommand command, DataSet dataSet, string[] tableNames)
        {
            Check.Require(tableNames != null && tableNames.Length > 0, "tableNames could not be null or empty.");
            Check.Require(dataSet != null, "dataSet could not be null.");

            using (DbDataAdapter adapter = GetDataAdapter())
            {
                WriteLog(command);

                ((IDbDataAdapter)adapter).SelectCommand = command;


                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);

            }
        }

13. Example

Project: Dos.ORM
Source File: Database.cs
View license
private void DoLoadDataSet(DbCommand command, DataSet dataSet, string[] tableNames)
        {
            Check.Require(tableNames != null && tableNames.Length > 0, "tableNames could not be null or empty.");
            Check.Require(dataSet != null, "dataSet could not be null.");

            using (DbDataAdapter adapter = GetDataAdapter())
            {
                WriteLog(command);

                ((IDbDataAdapter)adapter).SelectCommand = command;


                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);

            }
        }

14. Example

Project: surveyproject
Source File: SpSqlDatabase.cs
View license
void DoLoadDataSetWithoutAcceptChanges(IDbCommand command,
                           DataSet dataSe/n ..... /n //View Source file for more details /n }

15. Example

Project: cms
Source File: SqlHelper.cs
View license
private static void FillDataset(SqlConnection connection, SqlTransaction transaction, CommandType co/n ..... /n //View Source file for more details /n }

16. Example

Project: spring-net
Source File: AdoTemplateTests.cs
View license
[Test]
	    public void FillDataSetNoParams()
	    {
	        PopulateTestObjectsTable();
	        string sql = ValidateTestObjects(4);
	        DataSet dataSet;

	        dataSet = new DataSet();
	        adoOperations.DataSetFill(dataSet, CommandType.Text, sql, new string[] {"TestObjects"});
            Assert.AreEqual(1, dataSet.Tables.Count);
            Assert.AreEqual(4, dataSet.Tables["TestObjects"].Rows.Count);
	        
	        dataSet = new DataSet();
	        DataTableMappingCollection mappingCollection = 
	            new DataTableMappingCollection();
	        DataTableMapping testObjectsMapping = mappingCollection.Add("Table", "TestObjects");
	        testObjectsMapping.ColumnMappings.Add("TestObjectNo", "UserID");
	        testObjectsMapping.ColumnMappings.Add("Name", "UserName");
            adoOperations.DataSetFill(dataSet, CommandType.Text, sql, mappingCollection);
            Assert.AreEqual(1, dataSet.Tables.Count);
            Assert.AreEqual(4, dataSet.Tables["TestObjects"].Rows.Count);	        
	        foreach (DataRow testObjectRow in dataSet.Tables["TestObjects"].Rows)
	        {
	            Assert.IsNotNull(testObjectRow["UserID"]);
	            Assert.IsNotNull(testObjectRow["Age"]);
	            Assert.IsNotNull(testObjectRow["UserName"]);
	        }
	        
	    }

17. Example

Project: CodeBuilder
Source File: SqlHelper.cs
View license
private static void FillDataset(SqlConnection connection, SqlTransaction transaction, CommandType co/n ..... /n //View Source file for more details /n }

18. Example

Project: BizUnit
Source File: FactBasedRuleEngineStep.cs
View license
public override void Execute(Context context)
        {
            var fi = new System.IO.FileInfo(/n ..... /n //View Source file for more details /n }

19. Example

View license
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
        [global::System.CodeDom.Compiler/n ..... /n //View Source file for more details /n }

20. Example

Project: openpetra
Source File: Access.cs
View license
public int SelectUsingDataAdapterMulti(String ASqlStatement, TDBTransaction AReadTransaction, ref Da/n ..... /n //View Source file for more details /n }