Пример #1
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="daScopeContext"></param>
 /// <param name="dataAdapterCommand"></param>
 /// <param name="commandWrappersDataAdapter"></param>
 /// <returns></returns>
 internal static DbCommand GetDbCommand(DaScopeContext daScopeContext, DataAdapterCommand dataAdapterCommand, Dictionary <DataAdapterCommand, DbCommandWrapper> commandWrappersDataAdapter)
 {
     if (commandWrappersDataAdapter.ContainsKey(dataAdapterCommand))
     {
         DbCommandWrapper commandWrapper = commandWrappersDataAdapter[dataAdapterCommand];
         return(commandWrapper.GetDbCommand(daScopeContext));
     }
     return(null);
 }
Пример #2
0
        private void ConfigCommand(DataAdapterCommand dataAdapterCommand, string commandText, CommandType commandType, int commandTimeout)
        {
            DbCommandWrapper commandWrapper;

            if (!_commandWrappersDataAdapter.ContainsKey(dataAdapterCommand))
            {
                commandWrapper = new DbCommandWrapper(commandText, commandType);
                _commandWrappersDataAdapter.Add(dataAdapterCommand, commandWrapper);
            }
            else
            {
                commandWrapper                = _commandWrappersDataAdapter[dataAdapterCommand];
                commandWrapper.CommandText    = commandText;
                commandWrapper.CommandType    = commandType;
                commandWrapper.CommandTimeout = commandTimeout;
            }
            UpdateCommandOfDataAdapter(dataAdapterCommand, commandWrapper);
        }
Пример #3
0
        /// <summary>
        /// Update commands of DataAdater if the instance already exists
        /// </summary>
        /// <param name="dataAdapterCommand"></param>
        /// <param name="commandWrapper"></param>
        private void UpdateCommandOfDataAdapter(DataAdapterCommand dataAdapterCommand, DbCommandWrapper commandWrapper)
        {
            if (_dataAdapter != null)
            {
                switch (dataAdapterCommand)
                {
                case DataAdapterCommand.Select:
                    DataAdapter.SelectCommand = commandWrapper.GetDbCommand(DaScopeContext);
                    break;

                case DataAdapterCommand.Insert:
                    DataAdapter.InsertCommand = commandWrapper.GetDbCommand(DaScopeContext);
                    break;

                case DataAdapterCommand.Update:
                    DataAdapter.UpdateCommand = commandWrapper.GetDbCommand(DaScopeContext);
                    break;

                case DataAdapterCommand.Delete:
                    DataAdapter.DeleteCommand = commandWrapper.GetDbCommand(DaScopeContext);
                    break;
                }
            }
        }