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
Shay Rojansky
@roji
You need to target hotfix/4.0.11
So cherry-pick the commit from the main branch into hotfix/4.0.11
Sander Mol
@Nkmol
@roji Thanks for the response. I see no hotfix/4.0.11 branch on the upstream so I do not think I can target this. I do not think I can create this branch. Excuse me if I am missing some obvious...
Shay Rojansky
@roji
Sorry, my bad. 4.0.11 was published almost a year ago (https://www.nuget.org/packages/Npgsql/4.0.11). I've just pushed hotfix/4.0.12 which you can backport against.
Am not promising a quick release though.. This is a very old version that isn't really maintained any more..
Sander Mol
@Nkmol
Totally understandable... The PR is here npgsql/npgsql#3722. At least this would be an opportunity to support this behaviour in Power BI.
Sajan
@woodsongem
Hello All,
we are trying to implement Tri-Gram in .net core with entity framework(Npgsql.EntityFrameworkCore.PostgreSQL.Trigrams)+ postgresql.
looking for step to implement. please share if you have any. TIA
Shay Rojansky
@roji
@woodsongem check out the docs for the support translations you can use in LINQ: https://www.npgsql.org/efcore/mapping/translations.html#trigram-functions.
akshayjoyinfo
@akshayjoyinfo
@roji u are a magician. That ReloadTypes works like a charm. We are using this code only Integration testing part.
In that part we are running migration on Containerized dB in pipeline then migrate using nogsql et core migration. One of the migration we changed the db column to citext. So after mig we ran this problem solved
Sajan
@woodsongem
Good Morning All,
how to implement search on number? like we have bigint column type called EmpId. we need to implement search on EmpId. please share thoughts . TIA
Shay Rojansky
@roji
@woodsongem what is exactly your question, in SQL (WHERE "EmpId" = xxx)? With EF Core? In both cases there's lots of basic resources on the Internet...
Sajan
@woodsongem
no.. like this " where EmpId::text like '%151%'"
sample input : EmpId ==>
1000151
2000151
3000151
Sajan
@woodsongem

Hello All,
Any one implement unit test case for EF.Functions.TrigramsAreSimilar. ? we are getting below error while running test case . any idea to solve issue?

"The 'TrigramsAreSimilar' method is not supported because the query has switched to client-evaluation. This usually happens when the arguments to the method cannot be translated to server. Rewrite the query to avoid client evaluation of arguments so that method can be translated to server."

Shay Rojansky
@roji
@woodsongem post your query... It's not possible to help without that
asyed4u
@asyed4u:matrix.org
[m]
hi
The connection pool has been exhausted either raise max pool size (currently 100) or timeout (currently 15 sec.)”
Enviroment : asp.net core api 3.1
Environment : postgresql 12+
code as below
services.AddDbContextPool<AppDbContext>(options => options.UseNpgsql(DbDetails.DefaultDb));
currently in postgreqsql : 100 max connection
currrently in .net core : default 128 max
Akshay Bheda
@akshaybheda
Facing this issue after upgrading to latest package.
Npgsql.PostgresException (0x80004005): 42P01: relation "XX" does not exist
The Relation exists and same query works through pgadmin
Same error is generated for non relationship, Single Tables
Any clue?
Shay Rojansky
@roji
@asyed4u @akshaybheda very difficult to help you guys without any code
Submit issues with minimal, runnable code samples - that's the fastest way to get help
Akshay Bheda
@akshaybheda
@roji npgsql/efcore.pg#1859 Created this issue
I am blocked since last 4 days due to this and this is very crucial issue for me
can you please help?
Sajan
@woodsongem

sorry for that @roji . we implemented search functionality using EF.Functions.TrigramsAreSimilar and it's looking good. now we are trying to add unit test case for that search. er are getting below error message while running unit test method. if any one already face this issue. please share , how to fix this issue.
C# Implementation.
where(x=>EF.Functions.TrigramsAreSimilar(x.FirstName, searchText))

Error Message:
"The 'TrigramsAreSimilar' method is not supported because the query has switched to client-evaluation. This usually happens when the arguments to the method cannot be translated to server. Rewrite the query to avoid client evaluation of arguments so that method can be translated to server."

Sajan
@woodsongem

sample code:
Unit test case:

        [Fact]
        public void test()
        {
            imdbContext context = GetDBContect();
            Rating rating = new Rating();
            rating.AverageRating = 90;
            rating.NumVotes = 90;
            rating.Tconst = "TC891549";
            context.Add(rating);
            rating = new Rating();
            rating.AverageRating = 90;
            rating.NumVotes = 90;
            rating.Tconst = "TC15491";
            context.Add(rating);
            rating = new Rating();
            rating.AverageRating = 90;
            rating.NumVotes = 90;
            rating.Tconst = "TC15492";
            context.Add(rating);
            context.SaveChanges();
            IMDBProvider iMDBProvider = new IMDBProvider(context);
            IOrderedQueryable<Rating>  ratings = iMDBProvider.GetRatings();
           int ratingCount = ratings.Count();
        }

        private imdbContext GetDBContect()
        {
            DbContextOptions<imdbContext> options;
            var builder = new DbContextOptionsBuilder<imdbContext>();
            builder.UseInMemoryDatabase("DBTestDataBase");
            options = builder.Options;

            imdbContext imdbContext = new imdbContext(options);
            imdbContext.Database.EnsureDeleted();
            imdbContext.Database.EnsureCreated();
            return imdbContext;
        }

Provide code to search context:

public IOrderedQueryable<Rating> GetRatings()
        {
            string sortedBy = "AverageRating";

            return _context.Ratings
            .Where(x => EF.Functions.TrigramsAreSimilar(x.Tconst, "1549") ||
            EF.Functions.TrigramsAreSimilar(x.NumVotes.ToString(), "1549"))
            .OrderBy(p => EF.Property<object>(p, sortedBy));
        }

Error Message:
"The 'TrigramsAreSimilar' method is not supported because the query has switched to client-evaluation. This usually happens when the arguments to the method cannot be translated to server. Rewrite the query to avoid client evaluation of arguments so that method can be translated to server."

mevgenich
@mevgenich
Hey guys,
I'm just wondering when to expect hotfix 5.0.6 available on nuget.org? I'm waiting for a specific fix related to the "Home" env variable on AWS Lambda.
Chris Ochs
@gamemachine
If I'm querying a bytea it looks like postgres doesn't store it's length right? So if I want to use NpgsqlDataReader.GetBytes to avoid allocating I need to store the length in another column?
Alberto Passalacqua
@AlbertoPa
Hello, is there a known issue with preview 4 about connection errors? All seems to work fine in my setup, but when I issue an Update-Database in the package manager console, I have an error message saying there was an error when connecting to the DB. However, all operations work fine and the update is applied.
Shay Rojansky
@roji
@gamemachine PostgreSQL definitely knows the length of bytea, and Npgsql does too when reading it. If you want to use GetBytes to avoid allocating, that means you've already allocated a byte[] buffer to read into; you tell GetBytes how many maximum bytes to read (typically the size of your buffer), and GetBytes will tell you how much it read. If it's less than your buffer, great - you have the entire value. If not, you need to invoke GetBytes again (and possibly again) until you get the rest of the data.
@AlbertoPa no issue as far as I'm aware with preview4... If you think you're seeing an actual problem, please post an issue with a repro.
Alberto Passalacqua
@AlbertoPa
@roji thanks. All I am seeing is a very vague error saying there was a connection issue, but then everything works as expected. I'll try to repro on a clean template app with p5, since it is out :-)
Sam Shirley
@sshirley
Hi everyone. I'm wondering about the PostgresException type. There is a method on there called IsTransient (returns a bool). Does anyone know how that's calculated?
Nevermind. I found it. :-)
msmithmis
@msmithmis
Hello. Can someone show an example of how to send DEFAULT as a parameter in an npgsql update statement? An example query: UPDATE weather SET (temp_lo, temp_hi, prcp) = (temp_lo+1, temp_lo+15, DEFAULT). I want to send the values as parameters. I am not sure how to send DEFAULT, the other ones I can do.
Shay Rojansky
@roji
@msmithmis AFAIK you need to use a literal DEFAULT - I don't think there's any way to parameterize that.
msmithmis
@msmithmis
@roji Ok, thanks. I was hoping to replace parameters that were null with keyword DEFAULT since the field is defined as NOT NULL with a DEFAULT. I guess I will have to add code to leave out the field from the SQL if the value is null and should use the DEFAULT value.
Erik
@ErikOwsiak
@roji can npgsql be used with .net 5 & TimescaleDB ???
Atulin
@Atulin

I have a bit of an issue with using HashSet<T> properties.
I have a model like

class Thing {
  public HashSet<long> Foos { get; init; }
}

configured with

builder.Property(cr => cr.Foos)
    .HasConversion(
        v => new List<long>(v),
        v => new HashSet<long>(v)
    );

because Npg doesn't support HashSet<T> directly.
Problem is, doing .Add() or .Remove() on that property, and then SaveChangesAsync()ing them, doesn't actually update anything in the database

Atulin
@Atulin
A property with a backing property is what I came up with for a potential solution
class Thing
{
  public List<long> Foos { get; set; }
  [NotMapped]
  public HashSet<long> FoosProxy {
    get => new HashSet<long>(Foos);
    set => Foos = new List<long>(value);
  }
}