npgsql

statement for npgsql using parameter

自作多情 提交于 2020-01-06 03:27:07
问题 I pass the parameters in the sql query using the driver npgsql: SqlCommand = new NpgsqlCommand(); .... SqlCommand.CommandText = "SELECT id,name FROM table1 WHERE field1=:param2 ORDER BY name;"; SqlCommand.Parameters.AddWithValue("param2", 1); This query executed correctly and issued the necessary data, but as soon as I add parameter to the sql in the section "select" SqlCommand.CommandText = "SELECT id,name :param1 FROM table1 WHERE field1=:param2 ORDER BY name;"; SqlCommand.Parameters

.NET Core Npgsql.EntityFrameworkCore ILikeExpression

﹥>﹥吖頭↗ 提交于 2020-01-05 08:37:28
问题 I am using EntityFramework Core with Npgsql provider, perform ILIKE query works fine: var query = dbContext.countries .Where(w => (w.name != null && EF.Functions.ILike(w.name, $"{search}%") ); Query is translated into PostgreSQL's ILIKE, so far so good. I am also building a dynamic LINQ based on annotation - [Searchable] or [Orderable] properties in models - and I am trying to find out how to perform ILIKE using Expressions and Lambda. Code: // works, except it produces just LIKE which is

How to specify ApplicationName in NpgSql connection string

梦想与她 提交于 2020-01-03 17:15:14
问题 Is it possible to to specify ApplicationName in NpgSql connection string? The following resource usually helps, but it says nothing in this case: Npgsql connection strings 回答1: ApplicationName works for me - "Server=localhost;Port=5432;User Id=***;Password=***;Database=***;ApplicationName=test" . 回答2: In case there are people who searched for answer to this question, here is the solution: application_name=MyApp will not work for npgsql version 2.2.4.3 (Latest Released 2015-02-05) Change

Npgsql Connection Pool Stopping At MinPoolSize Connections

北城余情 提交于 2020-01-03 06:33:49
问题 First time working with Npgsql, although I've done other PostgreSQL programming. Npgsql 3.1.6, PostgreSQL 9.5. Visual Studio 2015 with .Net 4.5.1. I have a connection string that looks like this (same string is used every time, unmodified, for every DB connection attempt): Server=dbserver;SearchPath=network;Database=netinfo;User ID=netuser;Password=netpassword;Port=19491;CommandTimeout=300;Pooling=true;MaxPoolSize=75 This is a C# multi-threaded data collector for our network. Up to 32 threads

Ho do I read a postgresql citext field with npgsql 3.0.0?

瘦欲@ 提交于 2020-01-03 04:42:08
问题 Say I have a table called "exampletable" in postgresql with a 100 citext typed fields, let's call them "field1", "field2" etc... How do I read these fields using npgsql? Ideally I would like to use the following sql: select * from exampletable But when I execute the sql using npgsql 3.0.0 I get the following NotSupportedException : "The field field1 has a type currently unknown to Npgsql (OID 16466). You can retrieve it as a string by marking it as unknown, please see the FAQ..." To overcome

Entity Framework 6 - Npgsql - connection string error

邮差的信 提交于 2020-01-03 01:41:13
问题 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

How to read array field from database using c#?

情到浓时终转凉″ 提交于 2020-01-03 00:57:44
问题 I am using C# with postgresql. In the database I have a table named test and in this table I have a column named arr that it's datatype is double[] and I stored multiple record like this {1, 1, 2, 3, 0, 5, 1, 4} . Now, how to return those records into C# program and stored in a list for example List<double[]> arr1 = new List<double[]>(); Who can help me? 回答1: For array datatypes, all you have to do is cast the result as an array of double: NpgsqlConnection conn = new NpgsqlConnection

PLINQ on ConcurrentQueue isn't multithreading

北城以北 提交于 2020-01-02 17:50:24
问题 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

What happened to NpgsqlCopySerialize and NpgsqlCopyIn

自古美人都是妖i 提交于 2020-01-02 05:41:06
问题 I upgraded to npgsql 3.0.3 and discovered that NpgsqlCopySerialize and NpgsqlCopyIn where no longer part of the npgsql namespace. I made use of these classes in a streaming copy class that moved data from sql server to postgresql. Are there any classes that can be used to replace the functionality that these two classes provided? Thank you all for taking the time to read this. 回答1: Well obviously they're not in the git repo for version 3. There's no mention of it on the 3.0 migration docs

Unable to find or load Npgsql with Entity Framework

限于喜欢 提交于 2019-12-31 10:48:54
问题 I am totally lost. In Visual Studio 2015, I created a WCF Library Service project and defined the service and service interface. EntityFramework, EntityFramework.SqlServer, EntityFramework6.Npgsql, and Npgsql was installed with the NuGet console: PM> Install-Package EntityFramework6.Npgsql -Version 3.0.5 Setting the library service as startup then starting debug (f5) correctly read the available procedures. However, upon testing any procedure in the WcfSvcHost, I get the following error: The