Изменения документа Сценарии

Редактировал(а) Alexandr Fokin 2024/12/07 13:48

<
От версии < 1.2 >
отредактировано Alexandr Fokin
на 2023/10/31 19:41
К версии < 1.11 >
отредактировано Alexandr Fokin
на 2024/04/13 14:36
>
Изменить комментарий: К данной версии нет комментариев

Комментарий

Подробности

Свойства страницы
Содержимое
... ... @@ -1,6 +1,37 @@
1 -| |Can JSONB GIN indexes be specified in CodeFirst EntityFramework with NPGSQL?
1 +|(% style="width:141px" %) |(% style="width:1372px" %)
2 +|(% style="width:141px" %)[[JSON>>doc:Разработка.Схемы данных, контракты, форматы.Text.JSON.WebHome]] тип данных|(% style="width:1372px" %)(((
3 +|(% style="width:117px" %) |(% style="width:1238px" %)Can JSONB GIN indexes be specified in CodeFirst EntityFramework with NPGSQL?
2 2  [[https:~~/~~/stackoverflow.com/questions/54618858/can-jsonb-gin-indexes-be-specified-in-codefirst-entityframework-with-npgsql>>https://stackoverflow.com/questions/54618858/can-jsonb-gin-indexes-be-specified-in-codefirst-entityframework-with-npgsql]]
3 -|Parameters|{{code language="c#"}}public static class QueryParameterExtensions
5 +|(% style="width:117px" %)Тип столбца и свойства|(% style="width:1238px" %)(((
6 +JSON Mapping
7 +[[https:~~/~~/www.npgsql.org/efcore/mapping/json.html?tabs=data-annotations%2Cpoco>>https://www.npgsql.org/efcore/mapping/json.html?tabs=data-annotations%2Cpoco]]
8 +
9 +[[System. Text. Json>>doc:Разработка.NET.Библиотеки.Документы.Форматы данных и схемы.NET Json.System\. Text\. Json.WebHome]]
10 +Позволяет использовать JsonDocument и JsonElement.
11 +)))
12 +|(% style="width:117px" %)Отчистка JsonDocument|(% style="width:1238px" %)1) Вызываем Dispose в setter для предыдущего значения.
13 +2) Делаем сущность Disposable и строим отчистку через Dispose DbContext.
14 +|(% style="width:117px" %)Проблема форматирования|(% style="width:1238px" %)(((
15 +|(((
16 +Проблема указания параметров форматирования, с которыми будет выполняться чтение и запись json столбца.
17 +
18 +Serialization options for System.Text.Json support
19 +[[https:~~/~~/github.com/npgsql/efcore.pg/issues/1107>>https://github.com/npgsql/efcore.pg/issues/1107]]
20 +)))|
21 +|XO.EntityFrameworkCore.NpgsqlJsonSerializerOptions
22 +[[https:~~/~~/www.nuget.org/packages/XO.EntityFrameworkCore.NpgsqlJsonSerializerOptions/>>https://www.nuget.org/packages/XO.EntityFrameworkCore.NpgsqlJsonSerializerOptions/]]|
23 +|Простое решение - реализовать кастомный {{code language="c#"}}ValueConverter<JsonElement, string>{{/code}}, определив в нем {{code language="c#"}}JsonSerializerOptions{{/code}}|
24 +|
25 +
26 +{{{NpgsqlConnection.GlobalTypeMapper.Mappings
27 +
28 +}}}(((
29 +6.0.0
30 +[[https:~~/~~/github.com/npgsql/efcore.pg/issues/1107#issuecomment-945126627>>https://github.com/npgsql/efcore.pg/issues/1107#issuecomment-945126627]]
31 +)))|
32 +)))
33 +)))
34 +|(% style="width:141px" %)Parameters|(% style="width:1372px" %){{code language="c#"}}public static class QueryParameterExtensions
4 4  {
5 5   public static NpgsqlParameter StructToDbParameter<T>(
6 6   this T value,
... ... @@ -42,6 +42,6 @@
42 42   return new NpgsqlParameter<T>(name, type) { TypedValue = value };
43 43   }
44 44  }{{/code}}
45 -| |
76 +|(% style="width:141px" %) |(% style="width:1372px" %)
46 46  
47 47