Dynamic select from jsonb
See original GitHub issueHi,
I’m creating dynamic system and some values are stored in jsonb in Postgres. I would like to filter values from json by selecting like this:
select values->>name, values->>description from cms.contents c where c.type = 'product'
with linq query:
db.Contents.Select("name", "description")
because input is List<string>
How can I do that in linq2db? I tried something like SqlKata but I don’t want change my ORM because of a few jsonb columns. 😦
Thanks! Pavel
Issue Analytics
- State:
- Created 3 years ago
- Comments:12 (5 by maintainers)
Top Results From Across the Web
Postgres jsonb query for dynamic values - sql
Find rows containing a key in a JSONB array of records. Generate query dynamically. SELECT 'SELECT * FROM users WHERE experience @? '...
Read more >Can I select keys stored in a postgres jsonb column as ...
But what I'm curious is if I can somehow tell PG I want all keys in the JSONB column to be selected as...
Read more >Postgres jsonb query for dynamic values - DevPress官方社区
Find rows containing a key in a JSONB array of records. Generate query dynamically. SELECT 'SELECT * FROM users WHERE experience @? '...
Read more >Passing dynamic column names an data in json to query with
From above json i want to dynamically filter my table where col1 = 'test' and col2... This can be completly dynamic so there...
Read more >How to get value from JSON with dynamic key in Postgres
Basically, getting all key names that contain 'foo' from a column called 'objects'. SELECT keys FROM ( SELECT jsonb_object_keys(objects) as keys ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Yes, it is possible via dynamic expressions. Try to produce expression tree dynamically like this one:
Still cannot handle whole idea
For making projection whole dynamic, I think yes you have to create class dynamically. I need to check one solution, maybe we can convert JObject to Dictionary in projection automatically