Exemplo n.º 1
0
        // 增加一个参数
        protected override IDbDataParameter AddParameter(object value, ResolveToken token,
                                                         object dbType, int?size = null, int?precision = null, int?scale = null, ParameterDirection?direction = null)
        {
            if (value is bool)
            {
                value = ((bool)value) ? 1 : 0;
            }
            else if (value is Guid)
            {
                value  = ((Guid)value).ToByteArray();
                dbType = OracleDbType.Raw;
            }
            else if (value is DateTimeOffset)
            {
                var dto  = (DateTimeOffset)value;
                var zone = (dto.Offset < TimeSpan.Zero ? "-" : "+") + dto.Offset.ToString("hh\\:mm");
                value = new OracleTimeStampTZ(dto.DateTime, zone);
            }

            // 补充 DbType
            OracleParameter parameter = (OracleParameter)base.AddParameter(value, token, dbType, size, precision, scale, direction);

            parameter.DbType(dbType);
            return(parameter);
        }