Исходный код вики Сценарии
Версия 1.4 от Alexandr Fokin на 2024/02/24 15:13
Скрыть последних авторов
author | version | line-number | content |
---|---|---|---|
![]() |
1.3 | 1 | |(% style="width:141px" %) |(% style="width:1372px" %) |
2 | |(% style="width:141px" %)[[JSON>>doc:Разработка.Схемы данных, контракты, форматы.Text.JSON.WebHome]] тип данных|(% style="width:1372px" %)((( | ||
![]() |
1.1 | 3 | | |Can JSONB GIN indexes be specified in CodeFirst EntityFramework with NPGSQL? |
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]] | ||
![]() |
1.4 | 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]] | ||
![]() |
1.3 | 10 | Позволяет использовать JsonDocument и JsonElement. |
![]() |
1.4 | 11 | ))) |
![]() |
1.3 | 12 | | | |
13 | ))) | ||
14 | |(% style="width:141px" %)Parameters|(% style="width:1372px" %){{code language="c#"}}public static class QueryParameterExtensions | ||
![]() |
1.2 | 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 | } | ||
25 | |||
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}} | ||
![]() |
1.3 | 56 | |(% style="width:141px" %) |(% style="width:1372px" %) |
![]() |
1.1 | 57 | |
58 |