public static NpgsqlParameterCollection AddSlidingExpirationInSeconds( this NpgsqlParameterCollection parameters, TimeSpan?value) { if (value.HasValue) { return(parameters.AddParamWithValue( Columns.Names.SlidingExpirationInSeconds, NpgsqlTypes.NpgsqlDbType.Double, value.Value.TotalSeconds)); } else { return(parameters.AddParamWithValue(Columns.Names.SlidingExpirationInSeconds, NpgsqlTypes.NpgsqlDbType.Double, DBNull.Value)); } }
public static NpgsqlParameterCollection AddAbsoluteExpiration( this NpgsqlParameterCollection parameters, DateTimeOffset?utcTime) { if (utcTime.HasValue) { return(parameters.AddParamWithValue( Columns.Names.AbsoluteExpiration, NpgsqlTypes.NpgsqlDbType.TimestampTz, utcTime.Value)); } else { return(parameters.AddParamWithValue( Columns.Names.AbsoluteExpiration, NpgsqlTypes.NpgsqlDbType.TimestampTz, DBNull.Value)); } }
public static NpgsqlParameterCollection AddCacheItemValue(this NpgsqlParameterCollection parameters, byte[] value) { if (value != null && value.Length < DefaultValueColumnWidth) { return(parameters.AddParamWithValue( Columns.Names.CacheItemValue, NpgsqlTypes.NpgsqlDbType.Bytea, DefaultValueColumnWidth, value)); } else { // do not mention the size return(parameters.AddParamWithValue(Columns.Names.CacheItemValue, NpgsqlTypes.NpgsqlDbType.Bytea, value)); } }
public static NpgsqlParameterCollection AddAbsoluteExpiration( this NpgsqlParameterCollection parameters, DateTimeOffset?utcTime) { if (utcTime.HasValue) { // https://www.npgsql.org/doc/types/datetime.html // TimestampTz must be in UTC. // The Offset component of DateTimeOffset is discarded in npgsql <6.0.0 // In npgsql >= 6.0.0 this throws an InvalidCastException using DateTimeOffset with Offset != 0. return(parameters.AddParamWithValue( Columns.Names.AbsoluteExpiration, NpgsqlTypes.NpgsqlDbType.TimestampTz, utcTime.Value.UtcDateTime)); } else { return(parameters.AddParamWithValue( Columns.Names.AbsoluteExpiration, NpgsqlTypes.NpgsqlDbType.TimestampTz, DBNull.Value)); } }
public static NpgsqlParameterCollection AddCacheItemId(this NpgsqlParameterCollection parameters, string value) { return(parameters.AddParamWithValue(Columns.Names.CacheItemId, NpgsqlTypes.NpgsqlDbType.Text, CacheItemIdColumnWidth, value)); }