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.

Support many-to-many via array column instead of via a join table

See original GitHub issue

I am trying to generate the following sql with linq but no success so far:

SELECT
    t1.id,
    t2.id
FROM public.table1 t1
INNER JOIN public.table2 t2 ON ARRAY[t2.id]::bigint[] <@ t1.t2_ids;

Table1:

public class Table1
{
    public long Id { get;set; }
    public long[] T2Ids { get; set }
}

Table2:

public class Table2
{
    public long Id { get;set; }
}

Is this possible with LINQ?

Issue Analytics

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

github_iconTop GitHub Comments

4reactions
rojicommented, Jun 16, 2022

This is definitely not something that EF Core can generate at this point.

Note https://github.com/dotnet/efcore/issues/23523 which is about providing this for Cosmos (some info also in https://github.com/dotnet/efcore/issues/16920#issuecomment-989721078); the same work could be done for PostgreSQL as well. Keeping on the backlog.

0reactions
rojicommented, Apr 22, 2023
Read more comments on GitHub >

github_iconTop Results From Across the Web

Inner join "many-to-many" table rows as array
I know that Arrays are possible with PostgreSQL, but I don't get how to write such a query and probably already spent too...
Read more >
Convert right side of join of many to many into array
What I'd like to do is convert the right side of a join into an array so the result is one row. Example...
Read more >
join table by querying many to many relationship
Hi everyone! I am trying to select a specific row with its id which should be the join result of a many to...
Read more >
The best way to map a JPA and Hibernate many- ...
In this article, we are going to see how you can map a many-to-many database relationship using an intermediary entity for the join...
Read more >
Many-to-many relationships | ER Diagram
Many to many relationships in entity relationship diagrams explained. Draw ER diagrams and design database structures easily.
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