forked from ddrilling/AsbCloudServer
add default valueComparer on blob fields
This commit is contained in:
parent
78dca86f81
commit
12ff470d5f
@ -1,4 +1,5 @@
|
|||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.EntityFrameworkCore.ChangeTracking;
|
||||||
using Microsoft.EntityFrameworkCore.Metadata;
|
using Microsoft.EntityFrameworkCore.Metadata;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
@ -30,6 +31,13 @@ namespace AsbCloudDb
|
|||||||
builder.HasConversion(
|
builder.HasConversion(
|
||||||
s => System.Text.Json.JsonSerializer.Serialize(s, jsonSerializerOptions),
|
s => System.Text.Json.JsonSerializer.Serialize(s, jsonSerializerOptions),
|
||||||
s => System.Text.Json.JsonSerializer.Deserialize<TProperty>(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;
|
return builder;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user