Closed attiqe closed 5 years ago
Because this library uses Newtonsoft I would imagine you can use the the JsonConverterAttribute for this.
@Armarr that's not what I was asking, I know that we can do with it Value Conversions, following is an example of using it in an entity configuration file:
entity
.Property(s => s.OutstandingMatters)
.HasColumnType(Constants.DataType.JsonType)
.HasConversion(
v => JsonConvert.SerializeObject(v),
s => JsonConvert.DeserializeObject<List<User>>(s, new UserConverter()));
I wanted to know about the usage of the HasJsonValueConversion
for custom converters.
Since HasJsonValueConversion is effectively just wrapping Newtonsoft JsonConvert.se-/deserialize calls, I suppose @Armarr suggestion using JsonConverterAttribute should work for passing custom converters on your entities. I'll let you know when I have time to try it out.
Other than that there's no way of passing a converter directly for property at the moment.
Using [JsonConverter] attribute to pass custom converters works fine. Created an unit test showcasing their usage: caadae68308cd8a2a7b72044efde7ddb21410599
Hi,
Thanks for a wonderful library, it makes job easier and clean code is a bonus. I have customer converters for some objects. How can we make use of it?
Thanks, Attiqe