npgsql

PostgreSQL: 42883 Operator does not exist: timestamp without time zone = text

╄→尐↘猪︶ㄣ 提交于 2019-12-07 08:10:39
问题 I am using Npgsql 3.0.3.0 and PetaPoco latest version. When I run this command: var dateCreated = DateTime.Now; // just an example var sql = new Sql("WHERE date_created = @0", dateCreated.ToString("yyyy-MM-dd HH:00:00")); var category = db.SingleOrDefault<Category>(sql); I get the following error: Npgsql.NpgsqlException 42883: operator does not exist: timestamp without time zone = text I understand the error message is saying I'm trying to compare a timestamp (date) with a text, however for

Npgsql/ Postgresql: “function does not exist” error message when it does

人盡茶涼 提交于 2019-12-07 07:54:54
问题 scratching my head on this. There's a similar question that might be related at "function does not exist," but I really think it does and PostgreSQL function does not exist but the answer(s) does not seem very obvious. PostgreSQL 9.5. I have an Npgsql-based membership query that looks like this: using (var conn = new NpgsqlConnection(ConnectionString)) { conn.Open(); using (var comm = new NpgsqlCommand("get_user_by_username", conn)) { comm.CommandType = CommandType.StoredProcedure; comm

Batching separate prepared npgsql commands

邮差的信 提交于 2019-12-06 15:27:22
Say you have three prepared NpgsqlCommands. Because they must be executed separatedly. But sometimes two or all three must be executed at once (well, one after the other). Is there a way to batch and reuse these previously prepared commands using a single roundtrip to the server? (goal is to minimize latency) Now I use a fourth command and semicolon separate a copy of the original three commands, and prepare this -- but I assume this will use more resources at the server, and more SQL parsing at the npgsql client. Npgsql supports batching through including several statements in your

PLINQ on ConcurrentQueue isn't multithreading

别说谁变了你拦得住时间么 提交于 2019-12-06 10:18:54
I have the following PLINQ statement in a C# program: foreach (ArrestRecord arrest in from row in arrestQueue.AsParallel() select row) { Geocoder geocodeThis = new Geocoder(arrest); writeQueue.Enqueue(geocodeThis.Geocode()); Console.Out.WriteLine("Enqueued " + ++k); } Both arrestQueue and writeQueue are ConcurrentQueues . Nothing is running in parallel: While running, total CPU usage is about 30%, and this is with everything else running, too. I have 8 cores (Hyper-Threading on a Core i7 720QM with 4 physical cores), and 4 of the 8 cores have virtually no utilization at all. The rest run

Update Asp.net app to Npgsql 3 and removing Preload Reader

[亡魂溺海] 提交于 2019-12-06 09:55:35
问题 I have updated my ASP.NET app from NpgSQL 2.2.5 to 3.0.1. In the breaking changes it's specified that they have removed the Preload Reader support. So I remove it from the string connection. Testing my web app, I got the error "An operation is already in progress." specially in the linq query like this: var plugins = from p in _pluginRepository.GetPlugins() // this method return this: GetAll().OrderBy(p => p.Created) join e in _userPluginRepository.GetByUserId(user.Id).ToList() on p.Id equals

PostGIS Entity Framework

可紊 提交于 2019-12-06 08:13:11
问题 I am trying to use Npgsql and Npgsql.EntityFramework with a geography data type. I can write data to the database, but I'm unable to retrieve it. I am not sure if this is even possible, so I would appreciate any help. The class that represents the table looks like this: internal class Geo { [Key, Column("geo_test_id")] public int GeoId { get; set; } [Column("geography")] public byte[] Geography { get; set; } } Data insertion is done like this: var geog1 = System.Data.Spatial.DbGeography

MultipleActiveResultSets for postgresql and ado.net entity data model

寵の児 提交于 2019-12-06 06:45:20
问题 Im using visual studio, postgresql database and ado.net entity data model. In the connectionstring, Im unable set MultipleActiveResultSets=True . Usually when I connect to sql server with MultipleActiveResultSets=True , it works fine. but i cannot set the same with postgresql database. When I use this, I got the following error There is already an open DataReader associated with this Command which must be closed first. How do I solve this problem. 回答1: Multiple Active Result Sets (MARS) is a

How to tell from Npgsql exception if the call is worth a retry (transient fault strategy)

ε祈祈猫儿з 提交于 2019-12-06 02:45:24
I'm writing a service which will be connecting to a remote postgres server. I'm looking for a good way to determine which exceptions should be treated as transient (worth retrying), and how to define an appropriate policy for connecting to a remote database. The service is using Npgsql for the data access. The documentation says that Npgsql will throw a PostgresException for sql errors and an NpgsqlException for "server related issues". So far the best I have been able to come up with is to assume all exceptions that are not PostgresExceptions should be treated as possibly transient, worth

Npgsql BeginTextImport try import from file (not from STDIN)

情到浓时终转凉″ 提交于 2019-12-05 21:01:55
I try import data to postgresql table from file via npgsql BeginTextImport This is my code: public Object Copy(String sSchemaAndTableName, String sFilePath, Boolean bIsImport) { Boolean bRet = true; Object oResult = new Object(); NpgsqlConnection conn = new NpgsqlConnection(sConnectionString); NpgsqlCommand cmd = new NpgsqlCommand(); try { conn.Open(); NpgsqlTransaction transaction = conn.BeginTransaction(); if (File.Exists(sFilePath)) { try { if (bIsImport) { conn.BeginTextImport("COPY " + sSchemaAndTableName + " FROM '" + sFilePath + "';"); } else { conn.BeginTextExport("COPY " +

Postgresql fails specific query ONE time after Windows reboot

心已入冬 提交于 2019-12-05 20:23:50
I'm using Postgresql on Windows in a C# application. The problem I'm having is really weird and can be described as follows: I restart my Windows I run the program One specific query fails: SELECT COUNT(*) AS c FROM files WHERE total_bytes IS NOT NULL I run the program again and everything works normally Weird notes: I tried making another query before that one (even using the same table) and it worked: SELECT COUNT(*) AS c FROM files I wasn't able to reproduce the error restarting Postgresql. It only happens on a Windows reboot. And it happens only once. The exception traceback: Npgsql