Skip to content

System.Text.Json Serialization Regression in NET6 (Net5 worked) #61044

Closed

Description

Description

I Serialize a Class with an IQueryable in it, looks like this:

public class WebsocketResponse {
public object Response {get;set;}
}

Reproduction Steps

Test Project:

use following 2 nugets:

<PackageReference Include="linq2db" Version="3.5.1" />
<PackageReference Include="Microsoft.Data.Sqlite.Core" Version="5.0.11" />

and following code:

      using LinqToDB.Data;
      using System.IO;
      using System.Text.Json;
      
      using (var dc = new DataConnection("Sqlite", "Data Source=:memory:"))
      using (var ms = new MemoryStream())
      {
          using (var writer = new Utf8JsonWriter(ms))
          {
              JsonSerializer.Serialize(writer, new Response { Result = dc.GetTable<DbTable>() });
          }
      }
      
      public class DbTable
      {
          public string A { get; set; }
      }
      
      public class Response
      {
          public object Result { get; set; }
      }

Expected behavior

Serialization should work as it did before.

Actual behavior

System.NotSupportedException: 'The type 'LinqToDB.Linq.Table`1[...]' can only be serialized using async serialization methods.'

Regression?

Yes, this did work in Net5

Known Workarounds

No response

Configuration

No response

Other information

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions