npgsql

Could not create the driver from NHibernate.Driver.NpgsqlDriver

穿精又带淫゛_ 提交于 2019-12-08 21:30:48
问题 I've inherited a C#/NHibernate/MS SQL Server project and am new to NHibernate. One of the first tasks given to me was to migrate the database from MS SQL Server (2008 R2) to Postgresql 9.2. I'm using the Npgsql 2.0.12 (.net 2.0 version). The Mono.Security.dll and Npgsql.dll are included in my project References and they exist in my bin directory. When the code executes the following line: SessionFactory.OpenSession(); an exception is thrown with the message "Could not create the driver from

connect C# to PgBouncer

半腔热情 提交于 2019-12-08 14:09:03
问题 I am using C# and PostgreSQL. I have connected to PostgreSQL using Npgsql. Everthing is working fine. Now I want to use connection pooling with the help of PgBouncer tool.Database information has been set to PgBouncer. Because now PgBouncer will take care of connection to PostgreSQL database( If I am wrong, please correct me). But the problem is that , I could not find the way to connect PgBouncer in C#.If anyone has done the same , please tell me. Also is it good to use connection pooling in

How to modify the set value of update command npgsql postgresql c#

时光总嘲笑我的痴心妄想 提交于 2019-12-08 12:13:20
问题 i've been trying to modify an sql command for postgresql on c#. The line in comment quotes is the one working, but i need to change the set from pre-defined to variable. Although after using the same way to define it as a variable, with a text given by the user on another form, it doesnt seem to work. Which is the correct way to replace the "first_name" with a variable ? String oldname = Actor.oldname; String newname = Actor.newname; String column = Actor.columnname; try { string connstring =

What to do if MSB3277 occurs in asp net core app

柔情痞子 提交于 2019-12-08 07:02:58
问题 I am using a Database-Project referencing EntityFrameworkCore 2.1.3 package but the AspNetCore.App-metapackage contains EntityFrameworkCore 2.1.2. After bringing in my Database-Project I get this msbuild-warning: Warning MSB3277 Found conflicts between different versions of "Microsoft.EntityFrameworkCore" that could not be resolved. I´ve googled around a bit an I found this doc: https://docs.microsoft.com/en-us/aspnet/core/fundamentals/metapackage-app?view=aspnetcore-2.1 I´m using a third

Cannot select some rows with npgsql on a “Portuguese” database

丶灬走出姿态 提交于 2019-12-08 05:15:53
问题 I have a postgresql database that was created with "SQL_ASCII" and template "template0". It holds data in Portuguese so I have data such as "Não", "Feijão", "Avô". When I try to retrieve rows that have these kind of characters "~^" it does not work, otherwise it works. Errors: "Error parsing column 6 (sempresa=0 - String)"} Message = "Can not convert byte [C3] in index 0 of the code page specified for Unicode." I'm using Npgsql and Dapper <packages> <package id="Dapper" version="1.50.2"

Batching separate prepared npgsql commands

ⅰ亾dé卋堺 提交于 2019-12-08 04:48:31
问题 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

Entity Framework 6 - Npgsql - connection string error

淺唱寂寞╮ 提交于 2019-12-07 15:21:28
A tricky (and frustrating problem) - perhaps you folks may be clever enough to solve it: Problem I want to be able to read/write to my database using Entity Frameworks. I have got a simple app rails running on Heroku (straightforward scaffold). I want to connect to this database and manipulate records. The good news is that I can successfully connect to that database using npgsql. The bad news is that I cannot do it with Entity Frameworks. This is the error I’m receiving: System.Data.Entity.Core.ProviderIncompatibleException: An error occurred while getting provider information from the

How to implement Select For Update in EF Core

北慕城南 提交于 2019-12-07 13:18:39
问题 As far as I've understood it, there is no option in EF (and EF Core) to explicitly lock resources which I'm querying, but I'll need this functionality quite often and don't really feel like falling back to writing select statements every time I'll need it. Since I only need it for postgres and according to the spec FOR UPDATE is the last item in the query, the easiest I thought about implementing it was to get the select statement as described here: In Linq to Entities can you convert an

How can I provide the table name for a query as command parameter in Npgsql?

和自甴很熟 提交于 2019-12-07 12:32:35
问题 I want to provide the table name for a query as command parameters, like so: public class Foo { private const String myTableName = "mytable"; public void Bar() { NpgsqlCommand command = new NpgsqlCommand("SELECT * from :tableName", connection); command.Parameters.Add(new NpgsqlParameter("tableName", DbType.String)); command.Parameters[0].Value = myTableName; } } This seems to result in this query: "SELECT * from E'mytable'" which results in an error (mind the single quotes). Do I really need

PostgreSQL, Npgsql returning 42601: syntax error at or near “$1”

自闭症网瘾萝莉.ら 提交于 2019-12-07 08:21:54
问题 I'm trying to use Npgsql and/or Dapper to query a table and I keep running into Npgsql.PostgresException 42601: syntax error at or near "$1". Here is what I've got trying it with NpgsqlCommand: using (var conn = new NpgsqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["postgres"].ConnectionString)) { conn.Open(); using (NpgsqlCommand command = new NpgsqlCommand("select * from Logs.Logs where Log_Date > current_date - interval @days day;", conn)) { command.Parameters