title: .NET Core 3.1 with PostreSQL jsonb JsonDocument mapping not working because "The LINQ expression could not be translated"
body: <p>I tried following <a href="https://www.npgsql.org/efcore/mapping/json.html?tabs=data-annotations%2Cjsondocument" rel="nofollow noreferrer">Npgsql tutorial</a> regarding accessing json DOM via dynamic mapping. What is suggested in the tutorial is to use <code>JsonDocument</code> and then use <code>.GetProperty(string)</code> on it, but it seems that it's only accessible via <code>.RootElement</code> (which is a <code>JsonElement</code>, and it does contain <code>GetProperty</code> method).</p>
  <p>Either way, I get this exception:</p>
  <pre><code>System.InvalidOperationException: The LINQ expression 'DbSet&lt;GameEntity&gt;
  .Where(g =&gt; g.GameInfo.GetProperty(&quot;ReadableIdentifier&quot;).ToString() == __readableIdentifier_0)' 
  could not be translated. 
  Either rewrite the query in a form that can be translated, or switch to client evaluation explicitly 
  by inserting a call to either AsEnumerable(), AsAsyncEnumerable(), ToList(), or ToListAsync(). 
  </code></pre>
  <p>I have tried few solutions:</p>
  <ol>
  <li>Works: Adding <code>AsEnumerable()</code> to the query, but this defeats the purpose, as it gets all the data without actually accessing JSON data natively</li>
  <li>Works: changing to POCO instead - but this greatly limits the flexibility I want from the JSON Document</li>
  <li>Doesn't work: removing <code>services.AddNewtonsoftJson(...)</code> from <code>ConfigureServices(...)</code> in <code>Startup</code>, as that was needed for the controller responses to set <code>options.SerializerSettings.ReferenceLoopHandling </code></li>
  <li>Doesn't work: Dereferencing Newtonsoft.Json (I am using Swagger and it seems to require it).</li>
  </ol>
  <p>Ideally, I would love to see the query below work natively and with proper translation, without need to download all records before doing the operations:</p>
  <pre><code>var gameEntity = _context.Games
              .Include(x =&gt; x.Characters)
              //.AsEnumerable()
              .Where(x =&gt; x.GameInfo.GetProperty(&quot;ReadableIdentifier&quot;).ToString() == readableIdentifier)
              .FirstOrDefault();
  </code></pre>
  <p>Is there anything I miss?</p>