Ejemplo n.º 1
0
 public DbCommand GetDbCommand(DaScopeContext daScopeContext)
 {
     CheckDisposed();
     if (_command == null)
     {
         _command = DbCommandUtil.CreateCommand(daScopeContext, _commandText, _commandType, _commandTimeout);
     }
     return(_command);
 }
Ejemplo n.º 2
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);
 }
Ejemplo n.º 3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="daScopeContext"></param>
        /// <param name="commandText"></param>
        /// <param name="commandType"></param>
        /// <param name="commandTimeout"></param>
        /// <returns></returns>
        internal static DbCommand CreateCommand(DaScopeContext daScopeContext, string commandText, CommandType commandType, int commandTimeout)
        {
            if (daScopeContext == null)
            {
                throw new ArgumentNullException("daScopeContext");
            }
            DbCommand command = daScopeContext.ProviderFactory.CreateCommand();

            command.Connection     = daScopeContext.Connection;
            command.CommandText    = commandText;
            command.CommandType    = commandType;
            command.CommandTimeout = commandTimeout;
            if (daScopeContext.Transaction != null)
            {
                command.Transaction = daScopeContext.Transaction;
            }
            return(command);
        }
Ejemplo n.º 4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="daScopeContext"></param>
        /// <param name="commandWrappers"></param>
        /// <returns></returns>
        internal static DbDataAdapter CreateDataAdapterFromCommandWrappers(DaScopeContext daScopeContext, Dictionary <DataAdapterCommand, DbCommandWrapper> commandWrappers)
        {
            if (daScopeContext == null)
            {
                throw new ArgumentNullException("daScopeContext");
            }
            DbCommand selectCommand = GetDbCommand(daScopeContext, DataAdapterCommand.Select, commandWrappers);

            if (selectCommand == null)
            {
                throw new NullReferenceException("SelectCommand cannot be null");
            }
            DbDataAdapter dataAdapter = daScopeContext.ProviderFactory.CreateDataAdapter();

            dataAdapter.SelectCommand = selectCommand;
            dataAdapter.InsertCommand = GetDbCommand(daScopeContext, DataAdapterCommand.Insert, commandWrappers);
            dataAdapter.UpdateCommand = GetDbCommand(daScopeContext, DataAdapterCommand.Update, commandWrappers);
            dataAdapter.DeleteCommand = GetDbCommand(daScopeContext, DataAdapterCommand.Delete, commandWrappers);

            return(dataAdapter);
        }
Ejemplo n.º 5
0
 public DbCommandUtil(string commandText, string connectionStringSettingName, DataAdapterCommand _dataAdapterCommand)
     : this(commandText, CommandType.Text)
 {
     _daScopeContext          = new DaScopeContext(connectionStringSettingName);
     this._dataAdapterCommand = _dataAdapterCommand;
 }