LinqConnect Documentation
PropertyConfiguration Classes

This classes are intended to define mapping for properties. The PropertyConfiguration class is the base class for all property configuration. Its descendants have the specific methods for properties of specific types.

PropertyConfiguration Class

The PropertyConfiguration class has the following descendants:

The PropertyConfiguration class has the following methods:

SizablePropertyConfiguration Class

SizablePropertyConfiguration is an abstract parent class for StringPropertyConfiguration and BinaryPropertyConfiguration classes, that is used for defining mapping configuration for string and binary properties. The SizablePropertyConfiguration has the following public methods:

StringPropertyConfiguration Class

The StringPropertyConfiguration class is used for defining mapping configuration for string properties. Its public methods are listed below:

The StringPropertyConvention convention sets Unicode() for String columns by default if neither Unicode() nor NonUnicode() were executed explicitly for this property.

BinaryPropertyConfiguration Class

The BinaryPropertyConfiguration class is used for defining mapping configuration for Byte[] or LinqBinary properties. Its public methods are listed below:

NumericPropertyConfiguration Class

The NumericPropertyConfiguration class is used for defining mapping configuration for properties of type SByte, Int16, Int32, Int64, Byte, UInt16, UInt32, or UInt64. It is the base class for DecimalPropertyConfiguration. Its public methods are listed below:

DecimalPropertyConfiguration Class

The DecimalPropertyConfiguration class is used for defining mapping configuration for properties of type Decimal, Single, or Double. Its public methods are listed below:

DateTimePropertyConfiguration Class

The DateTimePropertyConfiguration class is used for defining mapping configuration for DateTime properties. Its public methods are listed below:

Data Type Generation

Nullable/NotNullable, MaxLength, FixedLength/VariableLength, Unicode/NonUnicode, Precision and Scale values are used by the ServerDataTypeConvention convention for defining ServerDataType if it is not defined. If ServerDataType is specified explicitly, there is no need to specify Nullable/NotNullable, MaxLength, FixedLength/VariableLength, Unicode/NonUnicode, Precision and Scale values.

However, still it is better to set Nullable/NotNullable explicitly for building LinqConnect metadata correctly, even though Nullable/NotNullable can be set by default conventions.

There is a point to set Unicode/NonUnicode parameters only in databases that treat Unicode and non-Unicode strings differently, for example, in Oracle.

Note:
When setting the precision for DateTime properties, you should take into account that some databases cannot store DateTime values with high precision. System.DateTime allows storing time values with 7 places after the decimal point; its accuracy is 100 nanoseconds. Oracle and SQLite can store values with such precision. MySQL does not have a data type to store fractional seconds. PostgreSQL TIMESTAMP data type theoretically can can store fractional seconds up to microseconds (6 places after the decimal point), however the precision may vary, and microsecond precision is not guaranteed.

Example:

builder.ComplexType<AddressType>()
    .Property(p => p.Country)
        .ColumnName(@"COUNTRY")
        .NotNullable()
        .MaxLength(100)
        .NonUnicode()
        .VariableLength();
 
builder.ComplexType<AddressType>()
    .Property(p => p.City)
        .ColumnName(@"CITY")
        .NotNullable()
        .ServerDataType(@"VARCHAR2(100) NOT NULL");