14 lines
No EOL
437 B
C#
14 lines
No EOL
437 B
C#
using System.Text.Json;
|
|
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
|
|
|
namespace IdentityShroud.Core.EFCore;
|
|
|
|
public class DictionaryToJsonConverter<TKey, TValue> : ValueConverter<Dictionary<TKey, TValue>, string>
|
|
where TKey : notnull
|
|
{
|
|
public DictionaryToJsonConverter() : base(
|
|
v => JsonSerializer.Serialize(v),
|
|
v => JsonSerializer.Deserialize<Dictionary<TKey, TValue>>(v) ?? new())
|
|
{
|
|
}
|
|
} |