Пример #1
0
        protected override IEnumerable <DatabaseModel.ProcedureParameter> GetStoredProcedureParametersUnordered(IDbConnection connection, string domain, string storedProcedureName)
        {
            using (DataTable dt = ((OdbcConnection)connection).GetSchema("ProcedureParameters", new string[] { null, domain, storedProcedureName }))
            {
                foreach (DataRow dr in dt.Rows)
                {
                    var parameter = new DatabaseModel.ProcedureParameter
                    {
                        Name       = dr["COLUMN_NAME"].ToString(),
                        DataType   = DatabaseModel.ParseDataType(dr["TYPE_NAME"].ToString()),
                        Precision  = dr["DECIMAL_DIGITS"] == DBNull.Value ? (int?)null : (short)dr["DECIMAL_DIGITS"],
                        Scale      = dr["NUM_PREC_RADIX"] == DBNull.Value ? (int?)null : (short)dr["NUM_PREC_RADIX"],
                        Size       = dr["COLUMN_SIZE"] == DBNull.Value ? (int?)null : (int)dr["COLUMN_SIZE"],
                        IsNullable = dr["IS_NULLABLE"].ToString() == "YES",
                        Position   = (int)dr["ORDINAL_POSITION"]
                    };
                    switch ((short)dr["COLUMN_TYPE"])
                    {
                    case 1: parameter.Direction = DatabaseModel.ParameterDirection.In; break;

                    case 2: parameter.Direction = DatabaseModel.ParameterDirection.InOut; break;

                    case 3: parameter.Direction = DatabaseModel.ParameterDirection.Out; break;

                    case 5: parameter.Direction = DatabaseModel.ParameterDirection.ReturnValue; break;
                    }
                    yield return(parameter);
                }
            }
        }
Пример #2
0
        protected override IEnumerable <DatabaseModel.ProcedureParameter> GetStoredProcedureParametersUnordered(IDbConnection connection, string domain, string storedProcedureName)
        {
            using (DataTable dt = ((OleDbConnection)connection).GetOleDbSchemaTable(OleDbSchemaGuid.Procedure_Parameters, new object[] { null, domain, storedProcedureName }))
            {
                foreach (DataRow dr in dt.Rows)
                {
                    var parameter = new DatabaseModel.ProcedureParameter
                    {
                        Name       = dr["PARAMETER_NAME"].ToString(),
                        DataType   = DatabaseModel.ParseDataType(dr["TYPE_NAME"].ToString()),
                        Precision  = dr["NUMERIC_PRECISION"] == DBNull.Value ? (int?)null : (int)dr["NUMERIC_PRECISION"],
                        Scale      = dr["NUMERIC_SCALE"] == DBNull.Value ? (int?)null : (short)dr["NUMERIC_SCALE"],
                        Size       = dr["CHARACTER_MAXIMUM_LENGTH"] == DBNull.Value ? (int?)null : dr["CHARACTER_MAXIMUM_LENGTH"] is decimal ? (int)(decimal)dr["CHARACTER_MAXIMUM_LENGTH"] : (int)(long)dr["CHARACTER_MAXIMUM_LENGTH"],
                        IsNullable = (bool)dr["IS_NULLABLE"],
                        Position   = (int)dr["ORDINAL_POSITION"]
                    };
                    switch ((int)dr["PARAMETER_TYPE"])
                    {
                    case 1: parameter.Direction = DatabaseModel.ParameterDirection.In; break;

                    case 2: parameter.Direction = DatabaseModel.ParameterDirection.InOut; break;

                    case 3: parameter.Direction = DatabaseModel.ParameterDirection.Out; break;

                    case 4: parameter.Direction = DatabaseModel.ParameterDirection.ReturnValue; break;
                    }
                    yield return(parameter);
                }
            }
        }