question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Showoff + guidance needed

See original GitHub issue

PostgreSQL supports array types, which are simple columns that contain an array of an arbitrary element type. Even multidimensional arrays are supported. I added support a while back for mapping CLR arrays to PostgreSQL arrays, and this works great - you can have an int[] property on your entity and have it mapped to a PostgreSQL array column in the database.

The next logical step is to also translate array operations - PostgreSQL also provides operators for indexing and searching arrays, and these operations can even be optimized by indices. So, a LINQ operation such ctx.SomeEntities.Where(e => e.SomeArray[0] == 3) could be translated into SQL WHERE "e"."SomeArray"[1] = 3.

I did manage to get several such operations mapped, including indexing, comparing arrays for equality and array length - you can take a look at this test suite to see what’s currently supported (that’s the showoff part).

However, since array operations aren’t simple methods which can be translated as usual, I had to create my own NpgsqlSqlTranslatingExpressionVisitor to identify these array operations (ExpressionType.ArrayIndex, Expression.ArrayLength) and pass them through for treatment by my NpgsqlQuerySqlGenerator. Since this kind of change goes a bit deeper than usual I thought I’d request a review from the team, here’s the branch in question.

I’m particularly unsure about the way I’m checking that the member expressions are QuerySourceReferenceExpression, as a way to only translate array operations which occur on a member of an EF Core DbSet object - I want to avoid performing translation on, say, some client-side value (see the Where_indexer_closure test for an example).

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:10 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
smitpatelcommented, Jul 19, 2017

@ajcvickers - Verified that all code needed to override is public and not in internal namespace.

0reactions
rojicommented, Jul 21, 2017

Have merged array operation translation support into Npgsql 2.0.0, thanks for all the guidance @smitpatel!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Showoff Setup Instructions
SHOWOFF Ships FREE on ALL Packages! ... It's everything you need to get started. ... Check out the SHOWOFF Set up Instructions below:...
Read more >
How to Handle a Show-Off Communicator
Characteristics of the show-off communicator includes the need to be the center of attention, need for constant acknowledgement, feeling over- ...
Read more >
SHOWFF Set Up Directions and Instructions
Looking for instruction on how to set up your SHOWOFF? The SHOWOFF art tent can be assembled by one person with these simple...
Read more >
What is the best way to deal with 'show-off' people?
Ignore. Show off people seek attention. If you are listening to them, they will keep going on and on. Get distracted and let...
Read more >
Assault on Echo Base Walkthrough - LEGO Star Wars
Approach the AT-AT from the side, and line up with the opening between its legs to make it through unscathed. Challenge #2: Show...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found