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

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

От версии 1.1 >
отредактировано Alexandr Fokin
на 2023/02/11 21:51
К версии < 1.4 >
отредактировано Alexandr Fokin
на 2024/02/24 15:13
>
Изменить комментарий: К данной версии нет комментариев

Комментарий

Подробности

Свойства страницы
Содержимое
... ... @@ -1,6 +1,58 @@
1 +|(% style="width:141px" %) |(% style="width:1372px" %)
2 +|(% style="width:141px" %)[[JSON>>doc:Разработка.Схемы данных, контракты, форматы.Text.JSON.WebHome]] тип данных|(% style="width:1372px" %)(((
1 1  | |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]]
5 +|Тип сущности|(((
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 +)))
3 3  | |
4 -| |
13 +)))
14 +|(% style="width:141px" %)Parameters|(% style="width:1372px" %){{code language="c#"}}public static class QueryParameterExtensions
15 +{
16 + public static NpgsqlParameter StructToDbParameter<T>(
17 + this T value,
18 + string name,
19 + NpgsqlDbType type
20 + )
21 + where T : struct
22 + {
23 + return new NpgsqlParameter<T>(name, type) { TypedValue = value };
24 + }
5 5  
26 + public static NpgsqlParameter StructToDbParameter<T>(
27 + this T? value,
28 + string name,
29 + NpgsqlDbType type
30 + )
31 + where T : struct
32 + {
33 + if (!value.HasValue)
34 + {
35 + return new NpgsqlParameter(name, type) { Value = DBNull.Value };
36 + }
37 +
38 + return new NpgsqlParameter<T>(name, type) { TypedValue = value.Value };
39 + }
40 +
41 + public static NpgsqlParameter ClassToDbParameter<T>(
42 + this T value,
43 + string name,
44 + NpgsqlDbType type
45 + )
46 + where T : class
47 + {
48 + if (value == null)
49 + {
50 + return new NpgsqlParameter(name, type) { Value = DBNull.Value };
51 + }
52 +
53 + return new NpgsqlParameter<T>(name, type) { TypedValue = value };
54 + }
55 +}{{/code}}
56 +|(% style="width:141px" %) |(% style="width:1372px" %)
57 +
6 6