Class NullAndTrimStringConverter
Converter for string values. Based on settings, it can convert null and System.DBNull.Value values to empty string and trim string value. Values are converted in boht directions - when saving to database and also when returning from database.
The converter cannot be directly instantiated. Instead of that, there are predefined static instances ConvertNull, TrimString and ConvertNullAndTrimString.
Converter can be used for example to ensure, that value going into the database will be empty string if the column
is set NOT NULL
.
Inheritance
Implements
Namespace: Kros.KORM.Converter
Assembly: Kros.KORM.dll
Syntax
public class NullAndTrimStringConverter : IConverter
Fields
ConvertNull
Instance of the converter with settings: ConvertNullValue is true, TrimStringValue is false.
Declaration
public static readonly NullAndTrimStringConverter ConvertNull
Field Value
Type | Description |
---|---|
NullAndTrimStringConverter |
ConvertNullAndTrimString
Instance of the converter with settings: ConvertNullValue is true, TrimStringValue is true.
Declaration
public static readonly NullAndTrimStringConverter ConvertNullAndTrimString
Field Value
Type | Description |
---|---|
NullAndTrimStringConverter |
TrimString
Instance of the converter with settings: ConvertNullValue is false, TrimStringValue is true.
Declaration
public static readonly NullAndTrimStringConverter TrimString
Field Value
Type | Description |
---|---|
NullAndTrimStringConverter |
Properties
ConvertNullValue
If true, the values null and System.DBNull for database are converted to empty string.
Declaration
public bool ConvertNullValue { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
TrimStringValue
If true and input value for database is string, it is trimmed (System.String.Trim).
Declaration
public bool TrimStringValue { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
Methods
Convert(Object)
Declaration
public object Convert(object value)
Parameters
Type | Name | Description |
---|---|---|
System.Object | value |
Returns
Type | Description |
---|---|
System.Object |
ConvertBack(Object)
Converts value
based on ConvertNullValue and TrimStringValue settings.
Declaration
public object ConvertBack(object value)
Parameters
Type | Name | Description |
---|---|---|
System.Object | value | Value to convert. |
Returns
Type | Description |
---|---|
System.Object |