Table of Contents

Class DataType

Namespace
Breeze.Core
Assembly
Breeze.Core.dll

The set of data types a Breeze query can refer to, and the conversions between the loosely typed values that arrive in a query and the CLR types an expression needs.

public class DataType
Inheritance
DataType
Inherited Members

Remarks

Each data type is a named singleton, declared as one of the static fields below. Constructing one registers it, so FromName(string) and FromType(Type) can find it afterwards. The names are part of the wire format - they are what the Breeze client writes into a query - so they cannot be changed without breaking clients.

Constructors

DataType(string)

Create a data type with no CLR type behind it, and register it under its name.

public DataType(string name)

Parameters

name string

The name used on the wire. FromName(string) looks it up by this.

DataType(string, Type)

Create a data type and register it under both its name and its CLR type.

public DataType(string name, Type type)

Parameters

name string

The name used on the wire. FromName(string) looks it up by this.

type Type

The CLR type it maps to. FromType(Type) looks it up by this.

Fields

Binary

A byte array, sent as base64. The only data type with no CLR type behind it, and so the only one that cannot be coerced.

public static DataType Binary

Field Value

DataType

Boolean

A bool.

public static DataType Boolean

Field Value

DataType

Byte

An 8-bit unsigned byte.

public static DataType Byte

Field Value

DataType

DateOnly

A DateOnly - a date with no time part.

public static DataType DateOnly

Field Value

DataType

DateTime

public static DataType DateTime

Field Value

DataType

DateTimeOffset

A DateTimeOffset. A plain DateTime coerces to one.

public static DataType DateTimeOffset

Field Value

DataType

Decimal

public static DataType Decimal

Field Value

DataType

Double

A double-precision double.

public static DataType Double

Field Value

DataType

Guid

A Guid, sent as its string form.

public static DataType Guid

Field Value

DataType

Int16

A 16-bit signed short.

public static DataType Int16

Field Value

DataType

Int32

A 32-bit signed int.

public static DataType Int32

Field Value

DataType

Int64

A 64-bit signed long.

public static DataType Int64

Field Value

DataType

Single

A single-precision float.

public static DataType Single

Field Value

DataType

String

A string.

public static DataType String

Field Value

DataType

Time

A TimeSpan, sent as an ISO 8601 duration such as "PT2H30M".

public static DataType Time

Field Value

DataType

TimeOnly

A TimeOnly - a time of day with no date.

public static DataType TimeOnly

Field Value

DataType

Methods

CoerceData(object?, DataType?)

Convert value to an object of the dataType

public static object? CoerceData(object? value, DataType? dataType)

Parameters

value object

The value as it arrived, usually a string or a boxed number. Null passes through unchanged.

dataType DataType

The data type to convert to. Null passes the value through unchanged.

Returns

object

The value as the data type's underlying CLR type.

CoerceList(IList, Type)

Convert list to IList of itemType. Handles case where itemType is enum and/or nullable.

public static IList CoerceList(IList list, Type itemType)

Parameters

list IList

The values to convert, typically the right-hand side of an 'In' clause.

itemType Type

The element type of the returned list.

Returns

IList

A new List<itemType> holding the coerced values.

FromName(string)

Look up a data type by the name a client sent.

public static DataType FromName(string name)

Parameters

name string

One of the names of the static fields above, e.g. "DateTimeOffset".

Returns

DataType

The matching data type.

Exceptions

KeyNotFoundException

No data type is registered under that name.

FromType(Type)

Look up the data type for a CLR type. A nullable type resolves to the same data type as the type it wraps.

public static DataType FromType(Type type)

Parameters

type Type

The CLR type, which may be a Nullable<T>.

Returns

DataType

The matching data type.

Exceptions

KeyNotFoundException

No data type maps to that CLR type - enums and entity types among them.

GetName()

The name this data type is known by on the wire, e.g. "Int32".

public string GetName()

Returns

string

GetUnderlyingType()

The CLR type this data type maps to, or null for Binary, which has none.

public Type? GetUnderlyingType()

Returns

Type