MySql.Data.MySqlClient.ProcedureCache.GetProcData C# (CSharp) Method

GetProcData() private static method

private static GetProcData ( MySqlConnection connection, string spName ) : DataSet
connection MySqlConnection
spName string
return System.Data.DataSet
        private static DataSet GetProcData(MySqlConnection connection, string spName)
        {
            string schema = String.Empty;
            string name = spName;

            int dotIndex = spName.IndexOf(".");
            if (dotIndex != -1)
            {
                schema = spName.Substring(0, dotIndex);
                name = spName.Substring(dotIndex + 1, spName.Length - dotIndex - 1);
            }

            string[] restrictions = new string[4];
            restrictions[1] = schema.Length > 0 ? schema : connection.CurrentDatabase();
            restrictions[2] = name;
            DataTable procTable = connection.GetSchema("procedures", restrictions);
            if (procTable.Rows.Count > 1)
                throw new MySqlException(Resources.ProcAndFuncSameName);
            if (procTable.Rows.Count == 0)
                throw new MySqlException(String.Format(Resources.InvalidProcName, name, schema));

            DataSet ds = new DataSet();
            ds.Tables.Add(procTable);

            // we don't use GetSchema here because that would cause another
            // query of procedures and we don't need that since we already
            // know the procedure we care about.
            ISSchemaProvider isp = new ISSchemaProvider(connection);
            string[] rest = isp.CleanRestrictions(restrictions);
            try
            {
                DataTable parametersTable = isp.GetProcedureParameters(rest, procTable);
                ds.Tables.Add(parametersTable);
            }
            catch (Exception) { }

            return ds;
        }
    }

Usage Example

コード例 #1
0
        private ProcedureCacheEntry AddNew(MySqlConnection connection, string spName)
        {
            ProcedureCacheEntry procData = ProcedureCache.GetProcData(connection, spName);

            if (this.maxSize > 0)
            {
                string cacheKey = this.GetCacheKey(spName, procData);
                int    hashCode = cacheKey.GetHashCode();
                lock (this.procHash)
                {
                    if (this.procHash.Keys.Count >= this.maxSize)
                    {
                        this.TrimHash();
                    }
                    if (!this.procHash.ContainsKey(hashCode))
                    {
                        this.procHash[hashCode] = procData;
                        this.hashQueue.Enqueue(hashCode);
                    }
                }
            }
            return(procData);
        }