Browse Source

Implement generic AbpJsonValueConverter

pull/2462/head
Aaron Chong 7 years ago
parent
commit
e754f3350f
  1. 16
      framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/EntityFrameworkCore/ValueConverters/AbpJsonValueConverter.cs

16
framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/EntityFrameworkCore/ValueConverters/AbpJsonValueConverter.cs

@ -0,0 +1,16 @@
using System.Collections.Generic;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Newtonsoft.Json;
namespace Volo.Abp.EntityFrameworkCore.ValueConverters
{
public class AbpJsonValueConverter<TPropertyType> : ValueConverter<TPropertyType, string>
{
public AbpJsonValueConverter()
: base(
d => JsonConvert.SerializeObject(d, Formatting.None),
s => JsonConvert.DeserializeObject<TPropertyType>(s))
{
}
}
}
Loading…
Cancel
Save