fluent-nhibernate icon indicating copy to clipboard operation
fluent-nhibernate copied to clipboard

Upgrading to 3.1.0 brakes UTC-DateTime-Convention

Open 1234Georg opened this issue 4 years ago • 0 comments

I am using fluent nHibernate with SQLite. And I am working with UTC-DateTime in my code. I added "DateTimeKind=Utc" to my sqllite connection string, and I am telling nHibernate that it should use UTC (IPropertyInstance.CustomType<UtcDateTimeType>())

These are my package refs

	<ItemGroup>
		<PackageReference Include="FluentNHibernate" Version="3.1.0" />
                <PackageReference Include="Microsoft.Data.Sqlite" Version="5.0.5" />
                <PackageReference Include="NHibernate.Caches.CoreMemoryCache" Version="5.7.0" />
		<PackageReference Include="System.Data.SqlClient" Version="4.8.2" />
	</ItemGroup>

This is my convention for UTC

    public class DateTimeAsUtcPropertyConvention : IPropertyConvention
    {
        public void Apply(IPropertyInstance instance)
        {
            if (instance.Type.Name == typeof(DateTime).Name || instance.Type.Name == typeof(DateTime?).Name)
            {
                instance.CustomType<UtcDateTimeType>();
            }
        }
    }

I had fluent-nhibernate 3.0.1 installed, which worked as expected: I am saving and getting a DateTime that has a UTC-kind and the correct date and time. When I upgrade fluent-nHibernate to 3.1.0 that doesn't work any more. I am saving UTC DateTime, but I get my local time with kind UTC.

Any ideas on this?

1234Georg avatar May 06 '21 15:05 1234Georg