Exemple #1
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="key"></param>
 /// <param name="value"></param>
 public void Add(string key, PgDatParameter value)
 {
     if (HasKey(key) == true)
     {
         this[key] = value;
     }
     else
     {
         BaseAdd(key, value);
     }
 }
Exemple #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>
        public PgDatParameter this[string key]
        {
            get
            {
                var _result = (PgDatParameter)BaseGet(key);
                if (_result == null)
                {
                    _result = new PgDatParameter();
                }

                return(_result);
            }
            set
            {
                BaseSet(key, value);
            }
        }
Exemple #3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="db_param"></param>
        /// <returns></returns>
        public static DateTime ToDateTime(this PgDatParameter db_param)
        {
            DateTime _result = DateTime.MinValue;

            if (db_param != null && db_param.Value != null)
            {
                if (db_param.Value is DateTime)
                {
                    _result = (DateTime)db_param.Value;
                }
                else if (db_param.Value is String && db_param.Type == NpgsqlDbType.TimestampTz)
                {
                    _result = Convert.ToDateTime(db_param.Value);
                }
            }

            return(_result);
        }
Exemple #4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="db_param"></param>
        /// <returns></returns>
        public static Double ToDouble(this PgDatParameter db_param)
        {
            Double _result = 0;

            if (db_param != null && db_param.Value != null)
            {
                if (db_param.Value is Double)
                {
                    _result = (Double)db_param.Value;
                }
                else
                {
                    _result = Convert.ToDouble(db_param.Value);
                }
            }

            return(_result);
        }
Exemple #5
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="db_param"></param>
        /// <returns></returns>
        public static bool ToBoolean(this PgDatParameter db_param)
        {
            var _result = false;

            if (db_param != null && db_param.Value != null)
            {
                if (db_param.Value is Boolean)
                {
                    _result = (bool)db_param.Value;
                }
                else if (db_param.Value is String && db_param.Type == NpgsqlDbType.Varchar)
                {
                    _result = db_param.Value.ToString() == "T";
                }
            }

            return(_result);
        }
Exemple #6
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="db_param"></param>
        /// <returns></returns>
        public static Int64 ToInt64(this PgDatParameter db_param)
        {
            Int64 _result = 0;

            if (db_param != null && db_param.Value != null)
            {
                if (db_param.Value is Int64)
                {
                    _result = (Int64)db_param.Value;
                }
                else if (db_param.Value is Int16 || db_param.Value is Int32 || db_param.Value is Int64)
                {
                    _result = Convert.ToInt64(db_param.Value);
                }
                else if (db_param.Value is String && db_param.Type == NpgsqlDbType.Numeric)
                {
                    _result = Convert.ToInt64(db_param.Value);
                }
            }

            return(_result);
        }
Exemple #7
0
        /// <summary>
        /// 만약 string 값을 decimal로 변환 하려고 하는 경우, SqlDbType이 Decimal이어야 합니다.
        /// </summary>
        /// <param name="db_param"></param>
        /// <returns></returns>
        public static decimal ToDecimal(this PgDatParameter db_param)
        {
            decimal _result = 0;

            if (db_param != null && db_param.Value != null)
            {
                if (db_param.Value is Decimal)
                {
                    _result = (decimal)db_param.Value;
                }
                else if (db_param.Value is Int16 || db_param.Value is Int32 || db_param.Value is Int64)
                {
                    _result = Convert.ToDecimal(db_param.Value);
                }
                else if (db_param.Value is String && db_param.Type == NpgsqlDbType.Numeric)
                {
                    _result = Convert.ToDecimal(db_param.Value);
                }
            }

            return(_result);
        }
Exemple #8
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="value"></param>
 public void Add(PgDatParameter value)
 {
     Add(value.Name, value.FieldType, value.Type, value.Direction, value.Value);
 }