Path: redb/redb.Export/Flat/FlatStorageType.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Export/Flat/FlatStorageType.cs
----
using redb.Export.Flat.Model;
namespace redb.Export.Flat;
///
/// Dialect-independent type of a flat column. Each dialect maps it to a column type and to the form
/// its bulk insert accepts.
///
public enum FlatStorageType
{
/// .
Int64,
/// .
Int32,
/// .
Int16,
/// .
Byte,
/// .
Double,
/// .
Single,
/// .
Decimal,
/// .
Boolean,
/// Unbounded text: strings, enum names and every type scheme sync stores as text.
Text,
/// Text that takes part in a unique constraint (a dictionary key).
KeyText,
/// .
Char,
/// .
Guid,
/// , a UTC reading.
DateTime,
/// .
DateTimeOffset,
/// .
Date,
/// .
Time,
/// .
Duration,
/// byte[].
Bytes
}
/// Chooses the of a column from its CLR type.
public static class FlatStorageTypes
{
/// Storage type of .
public static FlatStorageType Of(FlatColumn column)
{
var type = Nullable.GetUnderlyingType(column.ClrType) ?? column.ClrType;
if (type == typeof(long)) return FlatStorageType.Int64;
if (type == typeof(int)) return FlatStorageType.Int32;
if (type == typeof(short)) return FlatStorageType.Int16;
if (type == typeof(byte)) return FlatStorageType.Byte;
if (type == typeof(double)) return FlatStorageType.Double;
if (type == typeof(float)) return FlatStorageType.Single;
if (type == typeof(decimal)) return FlatStorageType.Decimal;
if (type == typeof(bool)) return FlatStorageType.Boolean;
if (type == typeof(char)) return FlatStorageType.Char;
if (type == typeof(Guid)) return FlatStorageType.Guid;
if (type == typeof(DateTime)) return FlatStorageType.DateTime;
if (type == typeof(DateTimeOffset)) return FlatStorageType.DateTimeOffset;
if (type == typeof(DateOnly)) return FlatStorageType.Date;
if (type == typeof(TimeOnly)) return FlatStorageType.Time;
if (type == typeof(TimeSpan)) return FlatStorageType.Duration;
if (type == typeof(byte[])) return FlatStorageType.Bytes;
return column.Role == FlatColumnRole.DictionaryKey ? FlatStorageType.KeyText : FlatStorageType.Text;
}
}