Add ValueToStringConverter

This commit is contained in:
sunkaixuna
2021-08-04 12:31:55 +08:00
parent 9075c4966d
commit a50c3e2601
2 changed files with 26 additions and 0 deletions

View File

@@ -0,0 +1,25 @@
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SqlSugar
{
public class ValueToStringConverter : JsonConverter
{
public override bool CanRead => false;
public override bool CanConvert(Type objectType) => objectType.IsValueType;
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
=> throw new NotSupportedException();
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
{
var str = value?.ToString();
writer.WriteValue(str);
}
}
}

View File

@@ -91,6 +91,7 @@
<Compile Include="Abstract\Reportable\ReportableProvider.cs" />
<Compile Include="Abstract\SaveableProvider\Storageable.cs" />
<Compile Include="DistributedSystem\Snowflake\SnowFlakeSingle.cs" />
<Compile Include="DistributedSystem\Snowflake\StringAttribute.cs" />
<Compile Include="Entities\ConfigQuery.cs" />
<Compile Include="Entities\ManyToManyConfig.cs" />
<Compile Include="Entities\SingleColumnsEntity.cs" />