Example #1
0
        /// <summary>
        /// <para>
        /// Populates the parameter collection for a command wrapper from the cache
        /// or performs a round-trip to the aQuery to query the parameters.
        /// </para>
        /// </summary>
        /// <param name="command">
        /// <para>The command to add the parameters.</para>
        /// </param>
        /// <param name="query">
        /// <para>The aQuery to use to set the parameters.</para>
        /// </param>
        public void SetParameters(DbCommand command, QueryBase query)
        {
            if (command == null)
            {
                throw new ArgumentNullException("Command");
            }
            if (query == null)
            {
                throw new ArgumentNullException("Query");
            }


            if (AlreadyCached(command, query))
            {
                AddParametersFromCache(command, query);
            }
            else
            {
                query.DiscoverParameters(command);
                IDataParameter[] copyOfParameters = CreateParameterCopy(command);

                this._cache.AddParameterSetToCache(query.ConnectionString, command, copyOfParameters);
            }
        }