From 12ff470d5f266386eaa4330d05cecb21013b0b78 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A4=D1=80=D0=BE=D0=BB=D0=BE=D0=B2?= Date: Mon, 4 Jul 2022 17:24:59 +0500 Subject: [PATCH] add default valueComparer on blob fields --- AsbCloudDb/EFExtentions.cs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/AsbCloudDb/EFExtentions.cs b/AsbCloudDb/EFExtentions.cs index 6f6dac34..5114120b 100644 --- a/AsbCloudDb/EFExtentions.cs +++ b/AsbCloudDb/EFExtentions.cs @@ -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(s, jsonSerializerOptions)!); + + ValueComparer valueComparer = new ( + (a,b) => a.GetHashCode() == b.GetHashCode(), + i => i.GetHashCode(), + i => i); + + builder.Metadata.SetValueComparer(valueComparer); return builder; }