npgsql

Query PostgreSQL with Npgsql and Entity Framework using unaccent

怎甘沉沦 提交于 2020-07-06 20:29:32
问题 Is possible to use Npgsql and Entity Framework 6 for query PostgreSQL ignoring accents? In play SQL it's possible to use the unaccent extension and could be indexed with a index also based in unaccent: select * from users where unaccent(name) = unaccent('João') In previous projects using MySql I could solve this problem just using a collation accent insensitive like utf8_swedish_ci but PostgreSQL lacks this kind of solution as far as I know. 回答1: If you use the Codefirst approach, you should

Entity Framework Core PostgreSQL json query

牧云@^-^@ 提交于 2020-06-13 09:07:12
问题 Always return empty results var collection = await _context.Settings .Select(s => new { s.SettingId, s.SettingParentId, SettingValue = s.SettingValue.GetProperty(lang) }) .Where(s => EF.Functions.JsonExists(s.SettingValue, lang)) .ToListAsync(); I try return only key from json but always return empty, when remove "select" works fine but i need only one key This is the model public class Setting { public string SettingId { get; set; } public string SettingParentId { get; set; } public

How to tell Entity Framework that my ID column is auto-incremented (AspNet Core 2.0 + PostgreSQL)?

徘徊边缘 提交于 2020-06-10 07:39:05
问题 Code is simple. Tag.cs entity: public partial class Tag { [Key] [DatabaseGenerated(DatabaseGeneratedOption.Identity)] public int Id { get; set; } public string Name { get; set; } public string Description { get; set; } } HomeController.cs class: public async Task<IActionResult> Index() { tagRepository.Insert(new Tag { Name = "name", Description = "description" }); await UnitOfWork.SaveChangesAsync(); // calls dbContext.SaveChangesAsync() return View(); } TagRepository.cs class: // Context it

Npgsql: One connection, multiple commands

戏子无情 提交于 2020-03-22 06:11:30
问题 is it possible to execute multiple NpgslqCommands against one connection? I mean like: conn.Open(); ExecuteCommandA(conn); ExecuteCommandB(conn); ExecuteCommandC(conn); conn.Close(); I believe, it should be possible, but is there any issue here? If there is a batch of commands to be executed, that could take a longer time, there is a chance the connection could be lost or some other error can happen. So it should be tested, right? Also can a command bring the connection into some kind error

How to deal with a text[] array field type in Npgsql?

半腔热情 提交于 2020-02-29 08:04:59
问题 I have a Postgres 12 database with a single table: CREATE TABLE public.messages ( sender text COLLATE pg_catalog."default", "timestamp" timestamp with time zone, message_id bigint, text text COLLATE pg_catalog."default", priority bigint, parameters text[] COLLATE pg_catalog."default" ) Now, when I want to use this table in met .NET Winforms (not .NET Core) application by right-clicking the project, add new item, ADO.NET Entitity Data Model, EF Code First from Database, configuring my

How to deal with a text[] array field type in Npgsql?

不打扰是莪最后的温柔 提交于 2020-02-29 08:04:41
问题 I have a Postgres 12 database with a single table: CREATE TABLE public.messages ( sender text COLLATE pg_catalog."default", "timestamp" timestamp with time zone, message_id bigint, text text COLLATE pg_catalog."default", priority bigint, parameters text[] COLLATE pg_catalog."default" ) Now, when I want to use this table in met .NET Winforms (not .NET Core) application by right-clicking the project, add new item, ADO.NET Entitity Data Model, EF Code First from Database, configuring my

How to deal with a text[] array field type in Npgsql?

百般思念 提交于 2020-02-29 08:04:15
问题 I have a Postgres 12 database with a single table: CREATE TABLE public.messages ( sender text COLLATE pg_catalog."default", "timestamp" timestamp with time zone, message_id bigint, text text COLLATE pg_catalog."default", priority bigint, parameters text[] COLLATE pg_catalog."default" ) Now, when I want to use this table in met .NET Winforms (not .NET Core) application by right-clicking the project, add new item, ADO.NET Entitity Data Model, EF Code First from Database, configuring my

Npgsql: Old floating point representation for timestamps not supported

泪湿孤枕 提交于 2020-02-28 08:58:46
问题 I've written a basic script that syncs data from a PostgreSQL database to another system, which executes in my test/development environment without issue, using: PostgreSQL 9.4 Npgsql dll version 3.0.3 Once we ran the script in the live production environment, we hit the following error: "Old floating point representation for timestamps not supported" Researching the issue, I found this is related to a "deprecated compile-time option of PostgreSQL which switches to a floating-point

Npgsql: Old floating point representation for timestamps not supported

旧巷老猫 提交于 2020-02-28 08:58:22
问题 I've written a basic script that syncs data from a PostgreSQL database to another system, which executes in my test/development environment without issue, using: PostgreSQL 9.4 Npgsql dll version 3.0.3 Once we ran the script in the live production environment, we hit the following error: "Old floating point representation for timestamps not supported" Researching the issue, I found this is related to a "deprecated compile-time option of PostgreSQL which switches to a floating-point

Transaction can't handle parallel commands via Task.WhenAll

眉间皱痕 提交于 2020-02-24 10:19:53
问题 I have some main table (like Companies) and a lot of dependent tables (like CompanyAddresses, CompanyPaymentInfos, etc.) in my Postgres DB: CREATE TABLE Companies ( Id uuid NOT NULL PRIMARY KEY, ...); CREATE TABLE CompanyAddresses( CompanyId uuid NOT NULL PRIMARY KEY REFERENCES Companies(Id), ...); CREATE TABLE CompanyPaymentInfos( CompanyId uuid NOT NULL PRIMARY KEY REFERENCES Companies(Id), ...); I use transactions from standard library in my C# code: private TransactionScope