Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Jan 31 2019 21:30
    roji commented #2307
  • Jan 31 2019 20:35
    YohDeadfall commented #2307
  • Jan 31 2019 10:20
    capan starred npgsql/npgsql
  • Jan 31 2019 06:10
    SeanFarrow synchronize #2308
  • Jan 30 2019 20:37
    austindrenski commented #2308
  • Jan 30 2019 20:37
    pentagra commented #1445
  • Jan 30 2019 20:33
    SeanFarrow commented #2308
  • Jan 30 2019 20:31
    austindrenski commented #2308
  • Jan 30 2019 20:27
    SeanFarrow commented #2308
  • Jan 30 2019 20:09
    austindrenski labeled #2308
  • Jan 30 2019 20:05
    roji commented #1520
  • Jan 30 2019 19:50
    gyzod commented #1445
  • Jan 30 2019 19:06
    SeanFarrow commented #1520
  • Jan 30 2019 18:54
    roji commented #1520
  • Jan 30 2019 18:53
    roji commented #1520
  • Jan 30 2019 18:52
    roji commented #2050
  • Jan 30 2019 18:45
    Trolldemorted commented #2050
  • Jan 30 2019 18:21
    SeanFarrow commented #1520
  • Jan 30 2019 18:16
    SeanFarrow review_requested #2308
  • Jan 30 2019 18:16
    SeanFarrow review_requested #2308
Shimmy
@weitzhandler
@FerrariF70 well, changing ICollection<T> to T[] seems to work. Is there a way to intercept the deserialization process so that ICollection<T> will work too? I rather keep my entities array-free and stick to ICollection<T>.
It works well saving the data. The problem only occurs when reading back from the db.
FerrariF70
@FerrariF70
@weitzhandler try Newtonsoft library
[JsonObject(IsReference = true)]
 public  class Customer<T>
 {
        public string Name { get; set; }
        public string LastName { get; set; }
        public ICollection<T> Orders { get; set; }
 }

 static void Main(string[] args)
{
            Customer<string> customer = new Customer<string>()
            {
                Name = "Client1",
                LastName ="...",
                Orders = new List<string>()
                {
                    "...",
                    "..."
                }
            };
            string data = JsonConvert.SerializeObject(customer);// Get data from database
            Customer<string> other = JsonConvert.DeserializeObject<Customer<string>>(data);
}
Shimmy
@weitzhandler
Is there a way to interfere with the Npgsql's serialization process or to configure it
(when data is loaded from db it's DEserialized, it's received from db as json and entitiy is filled with it as clr data, no?)
FerrariF70
@FerrariF70
I don't never used jsonb, but if it's serializing then in theory it should deserialize, what is exception do you get?
Shimmy
@weitzhandler

Thanks for bearing with me
npgsql/npgsql#3368

Is it possible to use INpgsqlTypeMapper via DI?

Shimmy
@weitzhandler
Still haven't figured out why, but changing the field type to ICollection<T> instead of HashSet<T> seems to be solving the problem
Adrian Ksiezarczyk
@adrianksiezarczyk

Hello.
I am using UseSnakeCaseNamingConvention extenstion method with communication to postgres by EFCore.
After migration to 5.0 there is error:

System.TypeLoadException: Method 'ProcessForeignKeyOwnershipChanged' in type 'EFCore.NamingConventions.Internal.UpperCaseNameRewriter' from assembly 'EFCore.NamingConventions, Version=1.1.0.0, Culture=neutral, PublicKeyToken=5d8b90d52f46fda7' does not have an implementation.

To be honest, I am not sure if is that strictly related to npgsql , but is there maybe anyone how has the same problem?

Adrian Ksiezarczyk
@adrianksiezarczyk
Ok, actually, I have upgraded this package to 5.0.0-rc1 EFCore.NamingConventions and it started working. I leave these comments in case of someone's similar problem :)
Yoh Deadfall
@YohDeadfall
Yes, the package should be shipped in one week or so. For now using rc is fine.
Kot
@kotx
Hey, I'm using Npgsql.NodaTime and Npgsql.EntityFrameworkCore.PostgreSQL.NodaTime and with optionsBuilder.UseNpgsql(o => o.UseNodaTime()); in my DbContext's OnConfiguring.
I am storing an Instant as a timestamp, but when I try to Update-Database it errors out with 42804: column "Timestamp" cannot be cast automatically to type timestamp without time zone. I don't quite understand why, is NodaTime not properly registering converters?
Side note, should I add NpgsqlConnection.GlobalTypeMapper.UseNodaTime() to OnConfiguring? It doesn't make any difference when I run Update-Database though.
Using ASP.NET Core 5 BTW.
I have been using DateTime (UTC) before changing it to NodaTime's Instant, that might be affecting my migration. Any pointers?
Weston
@ronnyek
does npgsql support ltree types yet? I know it was a thing where both postgres itself and npgsql needed support for binary types or something like that
looks like it was at least int he works, just couldnt tell if it should actually just be there with appropriate versions or not
Yoh Deadfall
@YohDeadfall
@ronnyek, the driver supports ltree starting 5.0.
Weston
@ronnyek
so I should be able to just have a Ltree type property and the ngpsql efcore driver will just work ?
Yoh Deadfall
@YohDeadfall
Probably, am not an EF user, but the driver used under the hood (just Npgsql) passes a string as any of ltree types if the type is specified by its name or NpgsqlDbType.
Therefore, I think it should be fine to provide the required type to EF to make it work (:
Weston
@ronnyek
I'll play with it
Alberto Passalacqua
@AlbertoPa
unrelated question, but I am not finding a way: I have an EF entity which refers to itself recursively an (unknown a priori) number of times. How do I query the whole tree? :-?
Shay Rojansky
@roji
@ronnyek @YohDeadfall re ltree, we only added support at the npgsql level - support would still need to be added to the EF provider. I've opened npgsql/efcore.pg#1592 to track this; just mapping the types is easy enough, but there's also translations for the functions...
akshayjoyinfo
@akshayjoyinfo
Hello, First of all I need to thank such a great lib orm for eg core to do anything possible honorable mentions are jsonb, text[]. Now I need help regarding array column
Tags: text[],
{horror, comedy, drama} this the data how do I search the this tags.colum from .net ef core. Does it support list<string>
context.Movies.Where(et=> et.tags.contains(search_tag)).tolist()?? Is this the way??
akshayjoyinfo
@akshayjoyinfo
Saw this example

class Program
{
static void Main(string[] args)
{
using var ctx = new BlogContext();
ctx.Database.EnsureDeleted();
ctx.Database.EnsureCreated();

    var results = ctx.Blogs.Where(b => b.Tags.Contains("A Value")).ToList();
}

}

public class BlogContext : DbContext
{
public DbSet<Blog> Blogs { get; set; }

protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
    => optionsBuilder.UseNpgsql("...");

}

public class Blog
{
public int Id { get; set; }
public string[] Tags { get; set; }
}

Is there any way to.do with list??
Shay Rojansky
@roji
There's a PR out just now for full support of List<T> with Contains, which should make it into 5.0.1 (this was planned for 5.0.0 but got left out)
Jeffrey Jones
@rurounijones_gitlab

Could someone check to see I am not doing something stupid here and that this looks like a bug. I am taking the latest Npgsql.EntityFrameworkCore.PostgreSQL.NetTopologySuite as the dependency in my project and it looks like there is a bug somewhere in that dependency tree (Not sure where it would be though).

Am doing a simple select on a table using EFCore syntax and the generated SELECT SQL is including a spurious u.unit_id field that doesn't exist in the table and is not specified in the EFCore model definition. More details in the Gist along with the code: https://gist.github.com/rurounijones/c4adc0b90d4cf47fb3bc480af814a989

Weston
@ronnyek
@YohDeadfall I am looking at the ltree thing... do you know if there is a way to map ltree onto these objects for ef (even if the efcore stuff isnt setup to create queries to appropriately filter execute all thsoe custom sql syntax for that?
eg, should I be able to set a specific type, ahve it stored / loaded from the db, and have to write custom queries, or none of that stuff will work without just a raw pgsqlcommand or something
I would like store tree structure data in postgres and honestly constructing a path like you do in ltree is a lot more convenient than a ton of parent id and funky querying
I'm almost inclined to have same convention for the path, but just use indexes and startswith
Yoh Deadfall
@YohDeadfall
There's no translation in EF, unfortunately, but for now you can write pure SQL for some queries involving type specific functions. @roji may suggest other workarounds.
glestwid
@glestwid
Hi guys, seem to have a bug
2020-12-02 02:57:45.6649| An error occured in queue LP-Siebel-AddClient| Common.RabbitMQ.RabbitQueue`1.OnMessageReceived | Npgsql.NpgsqlException (0x80004005): Received backend message ReadyForQuery while expecting CommandCompleteMessage. Please file a bug.
at Npgsql.NpgsqlConnector.ExecuteInternalCommand(Byte[] data, Boolean async, CancellationToken cancellationToken)
at Npgsql.NpgsqlConnector.Rollback(Boolean async, CancellationToken cancellationToken)
at Npgsql.NpgsqlTransaction.Rollback()
at Microsoft.EntityFrameworkCore.Storage.RelationalTransaction.Rollback()
Yoh Deadfall
@YohDeadfall
It depends on version you're using. Maybe fixed already.
glestwid
@glestwid

It depends on version you're using. Maybe fixed already.

Npgsql version 5.0, Npgsql.EntityFramework has 5.0 as well

Shay Rojansky
@roji
@glestwid can you open an issue with a runnable code sample for that?
Kieran Benton
@kieranbenton
Hi all, before I log an issue (I've given this a google but nothing recent seems to look similar) I'm getting the following running Npgsql 5, seems to be occurring after a RAISE EXCEPTION in postgres, and where I'm committing the transaction wrapping that raise (I'm not sure if thats semantically the right thing to be doing tbh, but its been like that in previous versions for a number of years):
System.NullReferenceException: Object reference not set to an instance of an object.
at Npgsql.NpgsqlConnector.StartUserAction(ConnectorState newState, NpgsqlCommand command, CancellationToken cancellationToken, Boolean attemptPgCancellation)
at Npgsql.NpgsqlConnector.StartUserAction(CancellationToken cancellationToken, Boolean attemptPgCancellation)
at Npgsql.NpgsqlTransaction.Commit(Boolean async, CancellationToken cancellationToken)
at Npgsql.NpgsqlTransaction.Commit()
Just wanted to check if this is known about before I dig in and try and build a repro? Seems similar to previous issues but those seem to all be cleared in 5?
James Houx
@jhouxzirrus
Just tried to connect to Postgres instance using and received this error: "28000: pg_hba.conf rejects connection for host "192.168.1.1", user "xxx", database "xxx", SSL off"
I used exactly the same credentials for DbBeaver and it connected fine
Any ideas why Postgres might be rejecting an NpgSQL connection attempt but not a DBeaver connection attempt???
I think the problem must stem from the fact that it thinks I'm connecting from 192.168.1.1 -- and honestly I have no idea how it thinks that's my ip address... moreoever, if it thinks that's my IP address, I have no idea how it even sent a response back to me.
James Houx
@jhouxzirrus
I'm on a VPN, which must be somehow causing an issue. DBeaver is accepted but Npgsql is not. hrm
Shay Rojansky
@roji
@kieranbenton don't remember any known issue with an NRE in 5.0, can you open an issue with a code sample?
James Houx
@jhouxzirrus
@roji Shay, would you have any ideas about the problem I described? I don't understand why I can connect from a database application (Dbeaver) just fine, but when I try npgsql, the database rejects it and thinks I'm connecting from 192.168.1.1 (which I'm not!). I can't figure out how this could even be a software issue..... all I have as evidence is that Dbeaver works and npgsql does not
James Houx
@jhouxzirrus
I spoke to my network engineer and he said that due to NAT translation, I really am connecting from 192.168.1.1. So that explains that. But still no idea why I can connect from Dbeaver but not npgsql
James Houx
@jhouxzirrus
@roji ok we finally got it resolved. For some reason Dbeaver must be connecting with SSL even though it says its off. We found that we had to use SSL to get a connection to accept. I added SSL to the connection string, and it fixed the problem