Hi,
Are there any plans to support Queries on JSONB fields using LinqConnect?
Thanks
JSONB Query Support
Re: JSONB Query Support
JSONB fields in LinqConnect are supported: https://www.devart.com/linqconnect/docs ... pping.html.
Could you please specify a query on JSONB which doesn't work? Tell us the expected and actual results.
Could you please specify a query on JSONB which doesn't work? Tell us the expected and actual results.
Re: JSONB Query Support
Hi, thanks for the response...
My issue is that I cannot find any way to query a JSONB field using LinqConnect nor can I find any examples of this. And other posts have suggested that this can only be done in DotConnect.
So how would I for example query "name" == "John" against a JSONB field using LinqConnect?
Thanks
My issue is that I cannot find any way to query a JSONB field using LinqConnect nor can I find any examples of this. And other posts have suggested that this can only be done in DotConnect.
So how would I for example query "name" == "John" against a JSONB field using LinqConnect?
Thanks
Re: JSONB Query Support
Please create a test table:
Generate the LinqConnect model and try this code (it returns one record):
This is the only way to work with JSONB in LinqConnect and EF Core.
In case you want ORM to generate json-specific SQL like "SELECT * FROM jsonb_test WHERE data ->> 'a' = '1'", it is supported in EF6: https://blog.devart.com/json-support-in ... resql.html.
Code: Select all
CREATE TABLE jsonb_test (
id serial primary key,
data jsonb
);
INSERT INTO json_test (data) VALUES
('{}'),
('{"a": 1}'),
('{"a": 2, "b": ["c", "d"]}'),
('{"a": 1, "b": {"c": "d", "e": true}}'),
('{"b": 2}');
Code: Select all
using (var context = new MyDataContext())
{
var result = context.JsonbTests.Where(a => a.Data == "{\"a\": 1}").ToList();
}
In case you want ORM to generate json-specific SQL like "SELECT * FROM jsonb_test WHERE data ->> 'a' = '1'", it is supported in EF6: https://blog.devart.com/json-support-in ... resql.html.
Re: JSONB Query Support
The PgSqlFunctions class, which allows using PostgreSQL-specific functions in LINQ to Entities, is supported in EF Core: viewtopic.php?f=3&t=42248.