SQL Json_value alternative in GraphQL with Hot Chocolate

37 Views Asked by At

I have a table with a string column that is formatted as json. I want to query my table by json. This is achievable with SQL

SELECT * 
  FROM [db].[dbo].[table]
  WHERE JSON_VALUE(ColName, '$.jsonkey') = "value"

Is it possible with GraphQl and Hot Chocolate?

I tried

public IQueryable<Class> GetById([ScopedService] AppDbContext context, string id)
        {
            return context.Classes.AsQueryable().Where(p => JObject.Parse(p.JsonCol)["id"].ToString() == id);
        }

Got an error:

"message": "The LINQ expression 'DbSet()\r\n .Where(p => JObject.Parse(p.JsonCol).get_Item("id").ToString() == __id_0)' could not be translated.

Any help would be appreciated.

0

There are 0 best solutions below