ClickHouseType
This attribute sets the ClickHouseDbParameter.ClickHouseType property value via a class property, forcing an explicit ClickHouse type name for the generated parameter.
Attribute
Example usage:
public class Person
{
public ulong Id { get; set; }
[ClickHouseType("Nullable(DateTime64(3))")]
public DateTime? CreatedDateUtc { get; set; }
}
Fluent Mapping
To configure via FluentMapper:
FluentMapper
.Entity<Person>()
.PropertyValueAttributes(e => e.CreatedDateUtc, new ClickHouseTypeAttribute("Nullable(DateTime64(3))"));
Retrieval
Retrieve the attribute via PropertyValueAttributeCache:
var attribute = PropertyValueAttributeCache
.Get<Person>(e => e.CreatedDateUtc)?
.FirstOrDefault(e => e.GetType() == typeof(ClickHouseTypeAttribute));
Or via PropertyValueAttributeMapper:
var attribute = PropertyValueAttributeMapper
.Get<Person>(e => e.CreatedDateUtc)?
.FirstOrDefault(e => e.GetType() == typeof(ClickHouseTypeAttribute));
We strongly suggest to always use the PropertyValueAttributeCache to maximize the performance.
The underlying driver infers a plain
DateTimeCLR parameter as whole-second precision. Writing sub-second values into aDateTime64(N)column silently truncates them unless the parameter’s ClickHouse type is stated explicitly, as in the example above.