Скрыть последних авторов
Alexandr Fokin 1.3 1 |(% style="width:141px" %) |(% style="width:1372px" %)
2 |(% style="width:141px" %)[[JSON>>doc:Разработка.Схемы данных, контракты, форматы.Text.JSON.WebHome]] тип данных|(% style="width:1372px" %)(((
Alexandr Fokin 1.6 3 |(% style="width:117px" %) |(% style="width:1238px" %)Can JSONB GIN indexes be specified in CodeFirst EntityFramework with NPGSQL?
Alexandr Fokin 1.1 4 [[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]]
Alexandr Fokin 1.8 5 |(% style="width:117px" %)Тип столбца и свойства|(% style="width:1238px" %)(((
Alexandr Fokin 1.4 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]]
Alexandr Fokin 1.3 10 Позволяет использовать JsonDocument и JsonElement.
Alexandr Fokin 1.4 11 )))
Alexandr Fokin 1.6 12 |(% style="width:117px" %)Отчистка JsonDocument|(% style="width:1238px" %)1) Вызываем Dispose в setter для предыдущего значения.
Alexandr Fokin 1.5 13 2) Делаем сущность Disposable и строим отчистку через Dispose DbContext.
Alexandr Fokin 1.7 14 |(% style="width:117px" %)Проблема форматирования|(% style="width:1238px" %)(((
Alexandr Fokin 1.10 15 |(((
Alexandr Fokin 1.7 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]]
Alexandr Fokin 1.10 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}}|
Alexandr Fokin 1.14 24 |(((
25 NpgsqlConnection.GlobalTypeMapper.Mappings
26 [[https:~~/~~/github.com/npgsql/efcore.pg/issues/1107#issuecomment-552182608>>https://github.com/npgsql/efcore.pg/issues/1107#issuecomment-552182608]]
Alexandr Fokin 1.15 27
28 6.0.0
Alexandr Fokin 1.14 29 )))
Alexandr Fokin 1.11 30
Alexandr Fokin 1.14 31 {{{
Alexandr Fokin 1.11 32
Alexandr Fokin 1.15 33
34 }}}
Alexandr Fokin 1.3 35 )))
Alexandr Fokin 1.7 36 )))
Alexandr Fokin 1.3 37 |(% style="width:141px" %)Parameters|(% style="width:1372px" %){{code language="c#"}}public static class QueryParameterExtensions
Alexandr Fokin 1.2 38 {
39 public static NpgsqlParameter StructToDbParameter<T>(
40 this T value,
41 string name,
42 NpgsqlDbType type
43 )
44 where T : struct
45 {
46 return new NpgsqlParameter<T>(name, type) { TypedValue = value };
47 }
48
49 public static NpgsqlParameter StructToDbParameter<T>(
50 this T? value,
51 string name,
52 NpgsqlDbType type
53 )
54 where T : struct
55 {
56 if (!value.HasValue)
57 {
58 return new NpgsqlParameter(name, type) { Value = DBNull.Value };
59 }
60
61 return new NpgsqlParameter<T>(name, type) { TypedValue = value.Value };
62 }
63
64 public static NpgsqlParameter ClassToDbParameter<T>(
65 this T value,
66 string name,
67 NpgsqlDbType type
68 )
69 where T : class
70 {
71 if (value == null)
72 {
73 return new NpgsqlParameter(name, type) { Value = DBNull.Value };
74 }
75
76 return new NpgsqlParameter<T>(name, type) { TypedValue = value };
77 }
78 }{{/code}}
Alexandr Fokin 1.3 79 |(% style="width:141px" %) |(% style="width:1372px" %)
Alexandr Fokin 1.1 80
81