//////////////////////////////////////////////////// public virtual IDataAdapter GetNewAdapter(DataRowState etatsAPrendreEnCompte, bool bDisableIdAuto, params string[] champsExclus) { CStructureTable structure = CStructureTable.GetStructure(m_type); m_etatsAPrendreEnCompte = etatsAPrendreEnCompte; m_tblExclusions = new Hashtable(); foreach (string strChamp in champsExclus) { m_tblExclusions[strChamp] = strChamp; } IDbDataAdapter adapter = (IDbDataAdapter)m_connexion.GetTableAdapter(structure.NomTableInDb); if (typeof(IObjetDonneeAutoReference).IsAssignableFrom(m_type)) { adapter = new C2iDataAdapterForClasseAutoReferencee(m_type, adapter); } adapter.TableMappings.Add("Table", structure.NomTable); adapter.SelectCommand = GetSelectCommand(structure); if ((etatsAPrendreEnCompte & DataRowState.Added) != 0) { adapter.InsertCommand = GetInsertCommand(structure, bDisableIdAuto, adapter); } else { adapter.InsertCommand = m_connexion.GetConnexion().CreateCommand(); adapter.InsertCommand.CommandText = GetCommandQuiFaitRien(); adapter.InsertCommand.Transaction = m_connexion.Transaction; } if ((etatsAPrendreEnCompte & DataRowState.Deleted) != 0) { adapter.DeleteCommand = GetDeleteCommand(structure); } else { adapter.DeleteCommand = m_connexion.GetConnexion().CreateCommand(); adapter.DeleteCommand.CommandText = GetCommandQuiFaitRien(); adapter.DeleteCommand.Transaction = m_connexion.Transaction; } if ((etatsAPrendreEnCompte & DataRowState.Modified) != 0) { adapter.UpdateCommand = GetUpdateCommand(structure); } else { adapter.UpdateCommand = m_connexion.GetConnexion().CreateCommand(); adapter.UpdateCommand.CommandText = GetCommandQuiFaitRien(); adapter.UpdateCommand.Transaction = m_connexion.Transaction; } return(adapter); }
//////////////////////////////////////////////////// public virtual IDataAdapter GetNewAdapter(DataRowState etatsAPrendreEnCompte, bool bDisableIdAuto, params string[] strExclusions) { IDbDataAdapter adapter = (IDbDataAdapter)m_connexion.GetTableAdapter(m_strNomTableInDb); if (m_connexion.IsInTrans()) { adapter.SelectCommand.Transaction = m_connexion.Transaction; } string strNomTableInContexte = m_connexion.GetNomTableInContexteFromNomTableInDb(m_strNomTableInDb); if (strNomTableInContexte == null) { strNomTableInContexte = m_strNomTableInDb; } adapter.TableMappings.Add("Table", strNomTableInContexte); DataSet ds = new DataSet(); adapter.FillSchema(ds, SchemaType.Mapped); DataTable table = ds.Tables[strNomTableInContexte]; if (table == null) { table = ds.Tables[m_strNomTableInDb]; if (table != null) { table.TableName = strNomTableInContexte; } } if ((etatsAPrendreEnCompte & DataRowState.Added) != 0) { adapter.InsertCommand = GetInsertCommand(table, adapter, bDisableIdAuto); } else { adapter.InsertCommand = m_connexion.GetConnexion().CreateCommand(); adapter.InsertCommand.CommandType = CommandType.Text; adapter.InsertCommand.CommandText = GetCommandQuiFaitRien(); adapter.InsertCommand.Transaction = m_connexion.Transaction; } if ((etatsAPrendreEnCompte & DataRowState.Deleted) != 0) { adapter.DeleteCommand = GetDeleteCommand(table, adapter); } else { adapter.DeleteCommand = m_connexion.GetConnexion().CreateCommand(); adapter.DeleteCommand.CommandType = CommandType.Text; adapter.DeleteCommand.CommandText = GetCommandQuiFaitRien(); adapter.DeleteCommand.Transaction = m_connexion.Transaction; } if ((etatsAPrendreEnCompte & DataRowState.Modified) != 0) { adapter.UpdateCommand = GetUpdateCommand(table, adapter); } else { adapter.UpdateCommand = m_connexion.GetConnexion().CreateCommand(); adapter.UpdateCommand.CommandType = CommandType.Text; adapter.UpdateCommand.CommandText = GetCommandQuiFaitRien(); adapter.UpdateCommand.Transaction = m_connexion.Transaction; } return(adapter); }