mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-12-26 22:25:49 +08:00
Add ValueToStringConverter
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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" />
|
||||
|
||||
Reference in New Issue
Block a user