Изменения документа Сценарии
Редактировал(а) Alexandr Fokin 2024/12/07 13:48
отредактировано Alexandr Fokin
на 2023/10/31 19:41
на 2023/10/31 19:41
отредактировано Alexandr Fokin
на 2023/02/11 21:51
на 2023/02/11 21:51
Изменить комментарий:
К данной версии нет комментариев
Комментарий
-
Свойства страницы (1 изменено, 0 добавлено, 0 удалено)
Подробности
- Свойства страницы
-
- Содержимое
-
... ... @@ -1,47 +1,6 @@ 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]] 3 -|Parameters|{{code language="c#"}}public static class QueryParameterExtensions 4 -{ 5 - public static NpgsqlParameter StructToDbParameter<T>( 6 - this T value, 7 - string name, 8 - NpgsqlDbType type 9 - ) 10 - where T : struct 11 - { 12 - return new NpgsqlParameter<T>(name, type) { TypedValue = value }; 13 - } 14 - 15 - public static NpgsqlParameter StructToDbParameter<T>( 16 - this T? value, 17 - string name, 18 - NpgsqlDbType type 19 - ) 20 - where T : struct 21 - { 22 - if (!value.HasValue) 23 - { 24 - return new NpgsqlParameter(name, type) { Value = DBNull.Value }; 25 - } 26 - 27 - return new NpgsqlParameter<T>(name, type) { TypedValue = value.Value }; 28 - } 29 - 30 - public static NpgsqlParameter ClassToDbParameter<T>( 31 - this T value, 32 - string name, 33 - NpgsqlDbType type 34 - ) 35 - where T : class 36 - { 37 - if (value == null) 38 - { 39 - return new NpgsqlParameter(name, type) { Value = DBNull.Value }; 40 - } 41 - 42 - return new NpgsqlParameter<T>(name, type) { TypedValue = value }; 43 - } 44 -}{{/code}} 45 45 | | 4 +| | 46 46 47 47