private static void InitalizeTableConfig(CompositeTag tableConfig, string dsName) { List <string> pKeys = new List <string>(); foreach (TagElement columnConfig in tableConfig.SubTags) { string isKey = columnConfig.TryGetAttributeValueAt("isKey"); isKey = isKey.ToLower(); if (isKey != null && isKey.Equals("yes")) { pKeys.Add(columnConfig.TryGetAttributeValueAt("id")); } } TablesWithSchema.SetPrimaryKey(dsName, tableConfig.TryGetAttributeValueAt("id"), pKeys.ToArray()); }
//private object Raw_GetStoredProcedureParameters(params object[] p) //{ // IDbCommand spCommand = this.CreateCommand(); // spCommand.CommandType = CommandType.StoredProcedure; // spCommand.CommandText = p[0] as string; // this.DeriveParameters(spCommand); // //spCommand.Dispose(); // return spCommand.Parameters; //} //private IDbCommand BuildStoredProcedureCommand(StoredProcedure proc, Hashtable table) //{ // ObjectPool spParamPool = ObjectPool.GetInstance(proc.SPName); // IDataParameterCollection parameters = (IDataParameterCollection)spParamPool.GetAndCacheObject(Raw_GetStoredProcedureParameters, proc.SPName); // IDbCommand spCommand = this.CreateCommand(); // spCommand.CommandType = CommandType.StoredProcedure; // spCommand.CommandText = proc.SPName; // spCommand.Parameters.Clear(); // foreach (StoredProcedureParameter pd in proc.ParameterList) // { // IDbDataParameter dbParameter = this.CreateDbParameter(pd.ParemName, null); // string pName = pd.ParemName; // ParameterDirection pDirection = pd.PDirection; // dbParameter.ParameterName = pName; // dbParameter.DbType = pd.DbType; // dbParameter.Direction = pDirection; // if (pDirection == ParameterDirection.Input) // { // dbParameter.Value = table[pName]; // } // else if (pDirection == ParameterDirection.InputOutput) // { // dbParameter.Value = table[pName]; // dbParameter.Size = pd.Size; // } // else if (pDirection == ParameterDirection.Output) // { // dbParameter.Size = pd.Size; // } // spCommand.Parameters.Add(dbParameter); // } // //处理编码等问题 // this.m_dbDialect.ProcessInputCommand(spCommand); // return spCommand; //} //public int ExecuteStoredProcedure(StoredProcedure proc, Hashtable table) //{ // IDbCommand spCommand = null; // try // { // spCommand = BuildStoredProcedureCommand(proc, table); // int ret = -1; // try // { // ret = spCommand.ExecuteNonQuery(); // //处理编码等问题 // this.m_dbDialect.ProcessOutputCommand(spCommand); // } // finally // { // foreach (StoredProcedureParameter pd in proc.ParameterList) // { // ParameterDirection pDirection = pd.PDirection; // if ((pDirection == ParameterDirection.Output) || (pDirection == ParameterDirection.InputOutput) || (pDirection == ParameterDirection.ReturnValue)) // { // string pName = pd.ParemName; // table[pName] = ((IDbDataParameter)spCommand.Parameters[pName]).Value; // } // } // } // return ret; // } // finally // { // if (spCommand != null) // { // try { spCommand.Dispose(); } // catch { } // } // } //} //public DataSet ExecuteStoredProcedureDataSet(StoredProcedure proc, Hashtable table) //{ // IDbCommand spCommand = null; // DbDataAdapter adapter = null; // try // { // spCommand = BuildStoredProcedureCommand(proc, table); // adapter = this.CreateDbDataAdapter(spCommand); // DataSet dataSet = new DataSet(); // try // { // adapter.Fill(dataSet); // //处理编码等问题 // this.m_dbDialect.ProcessDataSet(dataSet); // //处理编码等问题 // this.m_dbDialect.ProcessOutputCommand(spCommand); // } // finally // { // foreach (StoredProcedureParameter pd in proc.ParameterList) // { // ParameterDirection pDirection = pd.PDirection; // if ((pDirection == ParameterDirection.Output) || (pDirection == ParameterDirection.InputOutput) || (pDirection == ParameterDirection.ReturnValue)) // { // string pName = pd.ParemName; // table[pName] = ((IDbDataParameter)spCommand.Parameters[pName]).Value; // } // } // } // return dataSet; // } // finally // { // if (adapter != null) // { // try { adapter.Dispose(); } // catch { } // } // if (spCommand != null) // { // try { spCommand.Dispose(); } // catch { } // } // } //} public DataRow NewDataRow(string tableName) { return(TablesWithSchema.GetPrimaryKey(m_dataSourceName, tableName).NewRow()); }