#if MySQL

using System;
using System.Data;
using MySql.Data.MySqlClient;

namespace MrWu.DB {
    /// <summary>
    /// 存储过程查询键
    /// </summary>
    public class MySqlProcedureParameter : IProdureParameter<MySqlCommand> {

        MySqlCommand _command;

        /// <summary>
        /// 指令
        /// </summary>
        public MySqlCommand command {
            get => _command;
        }

        private string _dbName;

        /// <summary>
        /// 数据库名称
        /// </summary>
        public string dbName {
            get => _dbName;
        }

        /// <summary>
        /// 错误信息
        /// </summary>
        public Exception exception {
            get;
            set;
        }

        /// <summary>
        /// 是否报错
        /// </summary>
        public bool isException {
            get {
                return exception != null;
            }
        }

        private MySqlProcedureParameter() { }


        internal MySqlProcedureParameter(MySqlCommand mysqlcommand,string dbName) {
            this._command = mysqlcommand;
            this._dbName = dbName;
        }

        /// <summary>
        /// 释放
        /// </summary>
        public void Dispose() {
            if (_command != null) {
                _command.Dispose();
                _command = null;
            }
        }
    }

    /// <summary>
    /// 单独设置参数
    /// </summary>
    public class MySqlAloneParameter : ISqlAloneParameter<MySqlDbType> {

        string _paramname;

        /// <summary>
        /// 参数名称
        /// </summary>
        public string paramname {
            get => _paramname;
        }

        object _parmavalue;

        /// <summary>
        /// 参数值
        /// </summary>
        public object paramvalue {
            get => _parmavalue;
            set => _parmavalue = value;
        }

        MySqlDbType _type;

        /// <summary>
        /// 参数类型
        /// </summary>
        public MySqlDbType type {
            get => _type;
        }

        int _valueLength;

        /// <summary>
        /// 参数长度
        /// </summary>
        public int valueLength {
            get => _valueLength;
        }

        /// <summary>
        /// sql语句单独设置参数
        /// </summary>
        /// <param name="paramname">参数名称</param>
        /// <param name="paramvalue">参数值</param>
        /// <param name="valuelength">参数值的长度</param>
        /// <param name="type">参数类型</param>
        public MySqlAloneParameter(string paramname, object paramvalue, int valuelength, MySqlDbType type = MySqlDbType.Binary) {
            this._paramname = paramname;
            this._parmavalue = paramvalue;
            this._valueLength = valuelength;
            this._type = type;
        }

        /// <summary>
        /// Direction
        /// </summary>
        public ParameterDirection Direction { get; set; }
    }
}

#endif