Exemple #1
0
 /// <summary>
 /// 设置命令参数对象的 DbType属性
 /// </summary>
 /// <param name="parameter">命令参数对象</param>
 /// <param name="dbType">DbType属性</param>
 public static void DbType(this NpgsqlParameter parameter, object dbType)
 {
     if (dbType != null)
     {
         if (dbType is DbType)
         {
             parameter.DbType = (DbType)dbType;
         }
         else if (dbType is NpgsqlDbType)
         {
             parameter.NpgsqlDbType = (NpgsqlDbType)dbType;
         }
         else
         {
             NpgUtils.ThrowException(dbType);
         }
     }
 }
Exemple #2
0
 /// <summary>
 /// 是否日期+时间类型
 /// </summary>
 /// <param name="dbType">DbType属性</param>
 public static bool IsDateTime(object dbType)
 {
     if (dbType == null)
     {
         return(false);
     }
     else if (dbType is DbType)
     {
         return(((DbType)dbType) == System.Data.DbType.DateTime);
     }
     else if (dbType is NpgsqlDbType)
     {
         return(((NpgsqlDbType)dbType) == NpgsqlDbType.Timestamp);
     }
     else
     {
         return(NpgUtils.ThrowException(dbType));
     }
 }
Exemple #3
0
        /// <summary>
        /// 是否日期+时间+精度+时区类型
        /// </summary>
        /// <param name="dbType">DbType属性</param>
        public static bool IsDateTimeOffset(object dbType)
        {
#if netcore
            if (dbType == null)
            {
                return(false);
            }
            else if (dbType is DbType)
            {
                return(((DbType)dbType) == System.Data.DbType.DateTimeOffset);
            }
            else if (dbType is NpgsqlDbType)
            {
                return(((NpgsqlDbType)dbType) == NpgsqlDbType.TimestampTz);
            }
            else
            {
                return(NpgUtils.ThrowException(dbType));
            }
#endif
#if !netcore
            if (dbType == null)
            {
                return(false);
            }
            else if (dbType is DbType)
            {
                return(((DbType)dbType) == System.Data.DbType.DateTimeOffset);
            }
            else if (dbType is NpgsqlDbType)
            {
                return(((NpgsqlDbType)dbType) == NpgsqlDbType.TimestampTZ);
            }
            else
            {
                return(NpgUtils.ThrowException(dbType));
            }
#endif
        }