Specifying the returned dateTimeKind¶
By default, all columns of dateTime type will have a dateTimeKind of Unspecified. If you wish to specify either 'Local' or 'Utc', you can do so as follows:
(Optional) Add the setting to the App.config file:
<configuration>
<appSettings>
<add key="specifiedDateTimeKind" value ="Utc"/>
</appSettings>
(Optional) Load in and assign the specified DateTimeKind in an initialization:
public void Initialize()
{
var appSettingsReader = new AppSettingsReader();
_specifiedDateTimeKind = (DateTimeKind)Enum.Parse(typeof(DateTimeKind), (string)appSettingsReader.GetValue("specifiedDateTimeKind"typeof(string)));
}
When starting the service, add the specified datetime optional argument:
private Service CreateServiceWithDateTimeKind()
{
return new Service(_host, _port, _username, _password, _instanceName, _exclusive, _messagingServerConfigName, _tls, _specifiedDateTimeKind);
}