'Using to_jsonb in LINQ
I need to use the to_jsonb function in my LINQ. To get a code like this
SELECT ...
FROM Product AS a
WHERE jsonb_path_exists(to_jsonb(a), '$.* ? (@ like_regex "SOME TEXT")')
I haven't found anywhere how to use the to_jsonb function in EF CORE
Is there any way to solve this?
Solution 1:[1]
In the query given, you are attempting to filter on the entity you are querying in json format. Why do this? You should be able to simply add a WHERE to the given column that has the data you are looking for.
However, if this query is incorrect for some reason, try these:
See the Npgql docs here for mapping a jsonb column to a POCO type. Then, you'll be able to write LINQ against it.
If you don't want to do that, you can use RawSQL(), see EF Core docs here.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
