diff --git a/net/Sample/Converters.cs b/net/Sample/Converters.cs deleted file mode 100644 index 4f79413d..00000000 --- a/net/Sample/Converters.cs +++ /dev/null @@ -1,36 +0,0 @@ -#if NET6_0 -using System.Text.Json; -using System.Text.Json.Serialization; -#endif - -#if NET6_0 || NET7_0 -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -#endif - -#if NET6_0 -// TODO: Remove after migrate to net7+ -// https://devblogs.microsoft.com/dotnet/system-text-json-in-dotnet-7/ -// https://stackoverflow.com/questions/74246482/ -public sealed class Net6DateOnlyJsonConverter : JsonConverter { - public override DateOnly Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) => DateOnly.FromDateTime(reader.GetDateTime()); - public override void Write(Utf8JsonWriter writer, DateOnly value, JsonSerializerOptions options) => writer.WriteStringValue(value.ToString("O")); -} -public sealed class Net6TimeOnlyJsonConverter : JsonConverter { - public override TimeOnly Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) => TimeOnly.Parse(reader.GetString()); - public override void Write(Utf8JsonWriter writer, TimeOnly value, JsonSerializerOptions options) => writer.WriteStringValue(value.ToString("HH:mm:ss.fff")); -} -#endif - -#if NET6_0 || NET7_0 -public sealed class NetLess8DateOnlyValueConverter : ValueConverter { - public NetLess8DateOnlyValueConverter() : base( - dateOnly => dateOnly.ToDateTime(TimeOnly.MinValue), - dateTime => DateOnly.FromDateTime(dateTime)) { } -} - -public sealed class NetLess8TimeOnlyValueConverter : ValueConverter { - public NetLess8TimeOnlyValueConverter() : base( - timeOnly => timeOnly.ToTimeSpan(), - timeSpan => TimeOnly.FromTimeSpan(timeSpan)) { } -} -#endif diff --git a/net/Sample/Models/NorthwindContext.cs b/net/Sample/Models/NorthwindContext.cs index fdc7d688..26be9741 100644 --- a/net/Sample/Models/NorthwindContext.cs +++ b/net/Sample/Models/NorthwindContext.cs @@ -126,13 +126,5 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) { }); } -#if NET6_0 || NET7_0 - protected override void ConfigureConventions(ModelConfigurationBuilder configurationBuilder) { - base.ConfigureConventions(configurationBuilder); - configurationBuilder.Properties().HaveConversion(); - configurationBuilder.Properties().HaveConversion(); - } -#endif - } } diff --git a/net/Sample/Program.cs b/net/Sample/Program.cs index 3d2ee748..1e772db3 100644 --- a/net/Sample/Program.cs +++ b/net/Sample/Program.cs @@ -7,14 +7,7 @@ public static void Main(string[] args) { var builder = WebApplication.CreateBuilder(args); builder.Services .AddControllersWithViews() - //.AddRazorRuntimeCompilation() -#if NET6_0 - .AddJsonOptions(options => { - options.JsonSerializerOptions.Converters.Add(new Net6DateOnlyJsonConverter()); - options.JsonSerializerOptions.Converters.Add(new Net6TimeOnlyJsonConverter()); - }) -#endif - ; + .AddRazorRuntimeCompilation(); builder.Services .AddLogging() .AddEntityFrameworkSqlServer() diff --git a/net/Sample/Sample.csproj b/net/Sample/Sample.csproj index 77c36022..20c86fd5 100644 --- a/net/Sample/Sample.csproj +++ b/net/Sample/Sample.csproj @@ -1,7 +1,7 @@  - net6.0;net7.0;net8.0 + net8.0 enable @@ -9,33 +9,8 @@ - - - - NET6.0 - - - - - - - - - NET7.0 - - - - - - - - - NET8.0 - - - - - + +