Exemplo n.º 1
0
        //===============================================================================
        // Microsoft patterns & practices Enterprise Library
        // Data Access Application Block
        //===============================================================================
        // Copyright © Microsoft Corporation.  All rights reserved.
        // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY
        // OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT
        // LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
        // FITNESS FOR A PARTICULAR PURPOSE.
        //===============================================================================
        //
        // Forked From Enterprise Library licensed under Ms-Pl http://www.codeplex.com/entlib
        // but implementing a sub set of the API from the 2.0 Application Blocks SqlHelper
        // using implementation from the newer Ms-Pl version
        // Modifications by Joe Audette
        // Last Modified 2010-01-28

        public SqlParameter[] GetParameters(string connectionString, string procName)
        {
            if (string.IsNullOrEmpty(connectionString))
            {
                throw new ArgumentNullException("connectionString");
            }
            if (string.IsNullOrEmpty(procName))
            {
                throw new ArgumentNullException("Procedure Name");
            }


            if (AlreadyCached(connectionString, procName))
            {
                return(GetParametersFromCache(connectionString, procName));
            }
            else
            {
                SqlParameter[] copyOfParameters = DiscoverParameters(connectionString, procName);

                //this.cache.AddParameterSetToCache(connectionString, procName, copyOfParameters);
                SqlParameterCache.AddParameterSetToCache(connectionString, procName, copyOfParameters);

                return(GetParametersFromCache(connectionString, procName));
            }
        }
Exemplo n.º 2
0
        private static SqlParameter[] CreateParameterCopy(DbCommand command)
        {
            IDataParameterCollection parameters = command.Parameters;

            SqlParameter[] parameterArray = new SqlParameter[parameters.Count];
            parameters.CopyTo(parameterArray, 0);

            return(SqlParameterCache.CloneParameters(parameterArray));
        }
Exemplo n.º 3
0
 private bool AlreadyCached(string connectionString, string procName)
 {
     return(SqlParameterCache.IsParameterSetCached(connectionString, procName));
 }
Exemplo n.º 4
0
 protected SqlParameter[] GetParametersFromCache(string connectionString, string procName)
 {
     return(SqlParameterCache.GetCachedParameterSet(connectionString, procName));
 }