Open rabberbock opened 3 years ago
When you say 5.0.0-alpha.2 breaks query, did the same code work w/ 3.2?
Also I noted that Metadata field type is JObject, so shouldn't query be:
.Where(b => b.Metadata.Root["title"].Value<string>() == "My new Blog")
instead of:
.Where(b => b.Metadata["title"].Value<string>() == "My new Blog")
@mguinness Awesome, that did the trick!
When you say 5.0.0-alpha.2 breaks query, did the same code work w/ 3.2?
Yeah, this syntax worked in 3.2. Here is the repro for that https://github.com/rabberbock/PomeloMySqlJson/tree/netcore3.2.
@rabberbock Your original sample code works, if you use JToken
instead of JObject
.
However, I would have expected both of them to work and LINQ to JSON suggests that this should work as well. Also, I am not aware of any breaking changes in this area for 5.0, so whatever worked before for Newtonsoft.Json should have still worked.
So I will take a look at this.
Looks like this is a bug in EF Core upstream that got introduced in 5.0.
There are multiple possibilities for implementing a workaround by us, but all are a bit of a hack. So lets first see what the EF Core team says.
Alright, this has been fixed upstream and will ship with EF Core 5.0.1
.
Since there is a workaround (using the Root
property as @mguinness pointed out), I propose that we don't implement a temporary fix and just wait for the upstream release.
Steps to reproduce
Repro at https://github.com/rabberbock/PomeloMySqlJson
The issue
Json query for Newtonsoft JObject cannot be translated to DB query.
Further technical details
MySQL version: 8.0.17 Operating system: Windows 10 Pro Pomelo.EntityFrameworkCore.MySql version: 5.0.0-alpha.2 Microsoft.AspNetCore.App version: .Net 5
Thanks for all the amazing work!