npgsql

Is it possible to configure a custom provider for migrate.exe without using the machine.config

。_饼干妹妹 提交于 2019-12-11 10:24:49
问题 I am trying to setup automated migrations using migrate.exe that is provided in the EntityFramework v6 nuget package. My application uses a PostgreSQL database and uses a custom database provider (Npgsql), which requires additional configuration for EntityFramework. Migrate.exe works successfully if I add the required configuration into the machine.config, however this is not a practical solution as it requires editing the machine.config everywhere the migrations are run. I also want to set

Use string[][] with ngpsql

孤人 提交于 2019-12-11 10:13:27
问题 Its not supported? I get an exception when trying to insert data with command parameter set as: var parameter = ((IDbDataParameter)cmd.Parameters[index]); var list = (string[][])value; parameter.Value = list; With message System.NotSupportedException: This .NET type is not supported in Npgsql or your PostgreSQL: System.String[][] I'm using PostgreSQL 9.4 and created a column with type text[][] . Since text[] maps to string[] without any issues, I can't see a reason why two dimensional arrays

'Npgsql' already has a dependency defined for 'System.Threading.Tasks.Extensions'

坚强是说给别人听的谎言 提交于 2019-12-11 09:48:45
问题 Please help how to solve this? 'Npgsql' already has a dependency defined for 'System.Threading.Tasks.Extensions': I've already installed package System.Threading.Tasks.Extensions -Version 4.4.0 Install-Package System.Threading.Tasks.Extensions -Version 4.4.0 even after that I am unable to overcome this issue. 回答1: You can refresh the nupkg dll by downloading and copying it manually. Go to: https://www.nuget.org/packages/Npgsql/ Click: Manual download option. Open the nupkg downloaded file

Npgsql: How do Prepared Statements

[亡魂溺海] 提交于 2019-12-11 09:46:35
问题 we are developing a database backend for a multiplayer game. The server is written in C# and talks to a Postgres database via Npgsql. Now, the manual shows how to use prepared statements: NpgsqlCommand command = new NpgsqlCommand("select * from tablea where column1 = :column1", conn); // Now add the parameter to the parameter collection of the command specifying its type. command.Parameters.Add(new NpgsqlParameter("column1", NpgsqlDbType.Integer); // Now, prepare the statement. command

How to get the value of selected row from PostgreSQL in C#?

孤街醉人 提交于 2019-12-11 08:58:00
问题 I am using PostgreSQL database with C# and the Npgsql library. Right now I can select the last row in my table, but I can not figure out how to assign a C# variable to it. I know that my selection works, because I have successfully edited my last entry before. You can find my code below. Note that I have not pasted the rest of the methods as I think they are irrelevant. public void myMethod() { this.OpenConn(); //opens the connection string sql = "SELECT id FROM information_schema.tables

Mono 4.5 profile, entity framework Npgsql - NpgsqlSystem.InvalidCastException Cannot cast from source type to destination type

一曲冷凌霜 提交于 2019-12-11 08:29:57
问题 I have getting "System.InvalidCastException Cannot cast from source type to destination type." when trying to access the database from asp.net mvc3 using mono 4.5 profile and postgres at the backend. Here is what my code looks like: public class User { public int Id { get; set; } public string Username { get; set; } public string PasswordHash { get; set; } public string PasswordSalt { get; set; } } // class AppContext: using System; using System.Data.Entity; using Npgsql; using NpgsqlTypes;

How to programmatically find out which queries the psql command “\d+” does

旧城冷巷雨未停 提交于 2019-12-11 06:27:51
问题 I'm looking for a solution to generate postgreSQL database statistics programmatically. The psql commmand "\d+" is exactly what I need (output-wise), but so far I didn't find a way to retrieve this same data programmatically (by using C# and npgsql.dll). Any suggestions? Thanks in advance! 回答1: The answer is here: http://wiki.postgresql.org/wiki/Disk_Usage I find it useful to have a function: https://gist.github.com/ArtemGr/8434901 See also: PostgreSQL "DESCRIBE TABLE" 回答2: Apparently the

How do I set encoding in an NpgsqlConnection

爷,独闯天下 提交于 2019-12-11 06:08:02
问题 I have a PostgreSQL database, which uses character encoding WIN1252 . When querying the database, some records will produce an error when trying to read the data, because it is trying to convert it to UTF8 . This happens on some foreign names containing certain non-Latin characters. The error is: ERROR: 22P05: character with byte sequence 0x81 in encoding "WIN1252" has no equivalent in encoding "UTF8" It happens when I call Read() on the NpgsqlDataReader . My connection is defined as: new

Fastest way to move outlook emails to postgresql db using Npgsql

混江龙づ霸主 提交于 2019-12-11 05:41:54
问题 I have around 200 000 emails in outlooks public folders. Exporting to pst is a little bit fast but I don't know if psts are reliable. Also decoding it perfectly(with attachments) became a big headache. python lib doesn’t save attachments. Java lib not importing html body for all emails. So, I thought of saving to postgresql db. I am using Npgsql but it is slow(with the way I am using it). My current slow way: sql = "insert into tablename (a,b,c) values (:aa, :bb, :cc)"; cmd = (sql, con) #I am

reading an array column in C#

二次信任 提交于 2019-12-11 03:36:17
问题 My code is like this, but it gives an error: //array_field is an array of double values NpgsqlCommand Command = new NpgsqlCommand("SELECT array_fied from atable"); NpgsqlDataReader dr = Command.ExecuteReader(); while (dr.Read()) { double[] rrr = dr.GetDouble(dr.GetOrdinal("array_field")); } The error message is: cannot implicitly convert 'double' to 'double[]'. I tried other variations as well which also didn't work. thanks for your help Judit 回答1: Double[] rrr = dr["array_field"] as Double[]