npgsql

Calling a stored procedure in Postgresql through F# and Npgsql

﹥>﹥吖頭↗ 提交于 2019-12-04 03:26:06
问题 I am trying to call a stored procedure in postgresql from F# using the Npgsql type provider. Currently, I am connected to the database as follows: open System open System.Data open System.Data.Entity open System.Data.Linq open Microsoft.FSharp.Data.TypeProviders open Microsoft.FSharp.Linq open Npgsql open NpgsqlTypes type internal dbSchema = SqlEntityConnection<ConnectionString="**my connection string**", Provider="Npgsql"> let internal db = dbSchema.GetDataContext() However, I only see the

like statement for npgsql using parameter

穿精又带淫゛_ 提交于 2019-12-03 17:47:58
问题 I have a postgresql DB and i want to query the table "Locations" to retrieve the names of all the locations that match the name that's entered by the user. The column name is "LocationName". I'm using ASP.net with C#. NpgsqlConnection con = new NpgsqlConnection(ConfigurationManager.ConnectionStrings["ConnString"].ToString()); NpgsqlCommand cmd = new NpgsqlCommand("Select * from \"Locations\" where \"LocationName\" LIKE \"%@loc_name%\"", con); cmd.Parameters.AddWithValue("@loc_name", Location

npgsql and Entity Framework code first setup problems

落花浮王杯 提交于 2019-12-03 16:23:51
The most recent error im getting is ERROR: 42P01: relation "dbo.__MigrationHistory" does not exist but im convinced that this is just because something earlier hasnt been set up properly. Im currently trying to set up entity framework 4.4 code first to use Npgsql 2.0.12, I have done the following and it seems to atleast be connecting to the database now but giving me the above error when I do context.saveChanges(); Updated the machine.config for .net 2.0.50727 with; < add name="Npgsql Data Provider" invariant="Npgsql" support="FF" description=".Net Framework Data Provider for Postgresql Server

Case insensitive name of tables and properties in Entity Framework 7

让人想犯罪 __ 提交于 2019-12-03 15:35:25
I use Entity Framework 7 with Npgsql adapter. Sql generated by EF seems like SELECT "r"."Id", "r"."Name" FROM "public"."Role" AS "r" and it doesn't work in Postgres, because case-sensitive policy. To make it work i need to write create table script CREATE TABLE "Role" ( "Id" int, "Name" varchar(200) ); But it's ugly. Is there the way to make EF generate scripts without quotes or with lowercase naming style? Shay Rojansky There's a very good reason Npgsql generates quotes everywhere - so you definitely should not remove them (even if it's technically possible as @natemcmaster says). Identifiers

Inserting Large Object into Postgresql returns 53200 Out of Memory error

微笑、不失礼 提交于 2019-12-02 21:26:00
问题 Postgresql 9.1 NPGSQL 2.0.12 I have binary data I am wanting to store in a postgresql database. Most files load fine, however, a large binary (664 Mb) file is causing problems. When trying to load the file to postgresql using Large Object support through Npgsql, the postgresql server returns 'out of memory' error. I'm running this at present on a workstation with 4Gb RAM, with 2Gb free with postgresql running in an idle state. This is the code I am using, adapted from PG Foundry Npgsql User's

Castle Activerecord error is “relation does not exist” on Postgresql?

点点圈 提交于 2019-12-02 18:51:58
问题 ActiveRecord mape: [ActiveRecord("JobTitle",Schema="public")] public class JobTitle :ActiveRecordValidationBase<JobTitle> { [PrimaryKey(Column = "Id")] public virtual int Id { get; set; } [Property(Column = "Description")] public virtual string Description { get; set; } [Property(Column = "Title", NotNull = true)] public virtual string Title { get; set; } } DB connection: DB config: public class DbConfig { public static void Configure() { var connectionString=ConfigurationManager

How to use SQL parameters with NpgsqlDataAdapter?

早过忘川 提交于 2019-12-02 10:04:35
Is it possible to use parameters together with NpgsqlDataAdapter, as I can do with NpgsqlCommand: string sql = "SELECT * FROM tbl_student WHERE name = @val"; NpgsqlCommand command = new NpgsqlCommand(sql, conn); command.Parameters.AddWithValue("@val", name); I have this code, which displays the information about the students i a gridview: string sql = "SELECT * FROM tbl_student WHERE studentname = '" + name + "'"; DataSet ds = new DataSet(); DataTable dt = new DataTable(); NpgsqlDataAdapter da = new NpgsqlDataAdapter(sql, conn); ds.Reset(); da.Fill(ds); // filling DataSet with result from

Dapper parameters not working with PostgreSQL through npgsql connection, is postgres anonymous function parameterization supported?

二次信任 提交于 2019-12-02 07:22:11
问题 I'm trying to use dapper to parameterize a postgres anonymous function i've written to do an upsert. Here's the code: private static int UpsertProductPrice( IDbConnection connection, Data.ProductPrice price, List<Data.ProductPriceTier> priceTiers) { string postgres = @"DO $$ BEGIN UPDATE product_price SET start_date = @StartDate, end_date = @EndDate, price_tier_type = @PriceTierType WHERE product_price_external_id = @Id; IF found THEN RETURN; END IF; BEGIN INSERT INTO product_price(product

How to provide Npgsql with a custom data type as a parameter?

落花浮王杯 提交于 2019-12-02 06:52:40
问题 I want to pass an array of key-value pairs as an argument to a PostgreSQL function using Npgsql. I have the following type defined: drop type if exists key_value_pair create type key_value_pair as ( k varchar(250), v text ); I want to write a function like so: create or replace function persist_profile( _user_id integer, _key_value_pairs key_value_pair[] ) returns boolean as $$ begin; ... return true; end; $$ language plpgsql; How would I pass data from a IDictionary<string, string> object to

C# / Postgres / FluentNHibernate : configuring npgsql throws NotSupportedException

僤鯓⒐⒋嵵緔 提交于 2019-12-01 23:58:31
问题 Sometimes I really start wondering what's going on in my sourcecode: I'm trying to connect to PostGres 9.0 using npgsql 2.0.11.0, which I'm damn sure I already did, but right now, my program throws a NotSupportedException as it steps into the following : ISessionFactory sf = Fluently.Configure() .Database(PostgreSQLConfiguration.PostgreSQL82 .ConnectionString(c => c .Host("localhost") .Port(5432) .Database("cw") .Username("cw") .Password("mypass"))) .Mappings(x => x.FluentMappings