add default valueComparer on blob fields

This commit is contained in:
Фролов 2022-07-04 17:24:59 +05:00
parent 78dca86f81
commit 12ff470d5f

View File

@ -1,4 +1,5 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.ChangeTracking;
using Microsoft.EntityFrameworkCore.Metadata;
using System;
using System.Collections.Generic;
@ -30,6 +31,13 @@ namespace AsbCloudDb
builder.HasConversion(
s => System.Text.Json.JsonSerializer.Serialize(s, jsonSerializerOptions),
s => System.Text.Json.JsonSerializer.Deserialize<TProperty>(s, jsonSerializerOptions)!);
ValueComparer<TProperty> valueComparer = new (
(a,b) => a.GetHashCode() == b.GetHashCode(),
i => i.GetHashCode(),
i => i);
builder.Metadata.SetValueComparer(valueComparer);
return builder;
}