npgsql

PostgreSQL - best way to return an array of key-value pairs

旧时模样 提交于 2019-12-29 05:14:07
问题 I'm trying to select a number of fields, one of which needs to be an array with each element of the array containing two values. Each array item needs to contain a name (character varying) and an ID (numeric). I know how to return an array of single values (using the ARRAY keyword) but I'm unsure of how to return an array of an object which in itself contains two values. The query is something like SELECT t.field1, t.field2, ARRAY(--with each element containing two values i.e. {'TheName', 1 }

Npgsql query with search variable parameter returning empty result C# Postgres

杀马特。学长 韩版系。学妹 提交于 2019-12-25 09:28:34
问题 I am using Npgsql to query a database table and show the results on my page/view. The code works fine WITHOUT the where clause and parameters as it gets all the rows from the table onto the view. Now I am trying to incoporate a search string variable (if the user types in the string, then give me the table records that contain this string). My code is as follows string searchValue = TempData["String"].ToString(); var model = new List<ProductViewModel>(); NpgsqlConnection connection = new

Parse error in PostgreSQL parametrised query from C# but works in pgAdmin III

 ̄綄美尐妖づ 提交于 2019-12-25 04:04:10
问题 I am trying to execute a parametrised query from C# and I get the error: ERROR: XX000: parse error - invalid geometry with the hint "POLYGON((:m" <-- parse error at position 11 within geometry But when I run the query in pgAdmin III replacing the parameters with their values the query works. The code is command.CommandText = "SELECT area_code FROM area WHERE ST_INTERSECTS(ST_GeographyFromText('POLYGON((:minx :miny, :minx :maxy, :maxx :maxy, :maxx :miny, :minx :miny))'), shape) AND area_type

Install npgsql for PowerBI

自作多情 提交于 2019-12-24 17:24:39
问题 I'm not a programmer and I haven´t Visual Studio installed in my PC but I need npgsql to connect Microsoft PowerBI (Power Query) to a Postgres instance. Is there a way to install it without having to compile it? Is it necessary to do special configurations in my PC to make it work? Thank you very much. Javier 回答1: To expand on @Shay's comment, you can use nuget if you want the latest version of Npgsql. You don't need to install nuget.exe; you can down download the latest nuget package from

Trying to using EF 6 with PostgreSQL - Failed to find or load the registered .Net Framework Data Provider

房东的猫 提交于 2019-12-24 12:09:06
问题 I am trying to use EF 6 Code First with Npgsql provider. When I try to run Add-Migration command in package manager I have the following exception: Failed to find or load the registered .Net Framework Data Provider. PM> Add-Migration -Force -ConfigurationTypeName "TestDbContextMigration" -ConnectionString "Server=localhost;Port=5432;Database=test_db;User Id=test;Password=konnaya;" -ConnectionProviderName "Npgsql" cmdlet Add-Migration at command pipeline position 1 Supply values for the

PostgreSQL + Npgsql connector + MVC and SimpleMembership Not working

ぐ巨炮叔叔 提交于 2019-12-24 08:55:32
问题 I've test the db connection without Websecurity and it works. I've followed the tutorial from Brice Lambson http://brice-lambson.blogspot.com.es/2012/10/entity-framework-on-postgresql.html But when I use WebSecurity.InitializeDatabaseConnection("myContext", "UserProfile", "UserId", "UserName", autoCreateTables: false); I get this exception: System.InvalidOperationException was caught HResult=-2146233079 Message=No user table found that has the name "UserProfile". Source=WebMatrix.WebData

PostgreSQL + Npgsql connector + MVC and SimpleMembership Not working

五迷三道 提交于 2019-12-24 08:52:21
问题 I've test the db connection without Websecurity and it works. I've followed the tutorial from Brice Lambson http://brice-lambson.blogspot.com.es/2012/10/entity-framework-on-postgresql.html But when I use WebSecurity.InitializeDatabaseConnection("myContext", "UserProfile", "UserId", "UserName", autoCreateTables: false); I get this exception: System.InvalidOperationException was caught HResult=-2146233079 Message=No user table found that has the name "UserProfile". Source=WebMatrix.WebData

Npgsql connection string for local Postgres

左心房为你撑大大i 提交于 2019-12-24 03:07:45
问题 Good afternoon. I'm having troubles getting connected to a Postgres database. The app I'm working on has to run on .NET 4. I'm using Npgsql, and because I'm limited to .NET 4, I'm using Npgsql version 2.2.7 (I believe 3+ requires .NET 4.5). The application will be running on the same machine as Postgres is. The database is installed and set up by a third party, and for that reason I'm unable to change the pg_hba.conf file. My first stab at a connection string looked like this: Server

How to pass the parameter to a postgre function and get data using ExecuteReader?

怎甘沉沦 提交于 2019-12-23 23:25:47
问题 I am trying to retrieve all the columns from a table using ExecuteReader in C# application.Db is postgre.To test i created a console application following a tutorial which did showed how to query using a Function but not with passing parameters.The console application function for test static void Main(string[] args) { // Connect to a PostgreSQL database NpgsqlConnection conn = new NpgsqlConnection("Server=localhost;User Id=postgres; " + "Password=pes;Database=pmc;"); conn.Open(); // Define a

Entity Framework 6.1.1 and Npgsql 2.2.3: Compatible Entity Framework database provider could not be found

大憨熊 提交于 2019-12-23 15:28:56
问题 I am working on a project using EntityFramework 6.1.1 and npgsql 2.2.3 within Visual Studio 2012 Update 4. To do so I installed npgsl using the supplied setup and installed the nuget packages "Npgsql" and "Npgsql for Entity Framework" (and "EntityFramework" itself, of course). Every thing used to be fine: I could successfully access my database for a while - until at some day everything "blew up". This is the event history: Fixing compiler errors after a major code upgrade I encountered these