UtcDateTimeConverter.ConvertToStorageType(Object) Method
Converts the persistent property’s value from the current local time to coordinated universal time (UTC). The converted value is stored in the data store.
Namespace: DevExpress.Xpo.Metadata
Assembly: DevExpress.Xpo.v24.2.dll
NuGet Package: DevExpress.Xpo
#Declaration
#Parameters
Name | Type | Description |
---|---|---|
value | Object | An object which represents the value to convert. |
#Returns
Type | Description |
---|---|
Object | An object which represents the converted value. null (Nothing in Visual Basic) if the specified value is a null reference. |
#Remarks
The ConvertToStorageType method converts the property’s value from the current local time to coordinated universal time (UTC).
#Example
The following example shows how to convert the value of the Date property from the local time to the current coordinated universal time (UTC) when persisting it in a data store.
using DevExpress.Xpo;
using DevExpress.Xpo.Metadata;
// ...
public class SampleUtc : XPObject {
private DateTime date;
[ValueConverter(typeof(UtcDateTimeConverter))]
public DateTime Date {
get { return date; }
set { SetPropertyValue(nameof(Date), ref date, value); }
}
}