.Net Core 3.0 possible object cycle was detected which is not supported

前端 未结 8 1723
我寻月下人不归
我寻月下人不归 2020-12-02 09:27

I have 2 entities that are related as one to many

public class Restaurant {
   public int RestaurantId {get;set;}
   public string Name {get;set;}
   public          


        
8条回答
  •  感情败类
    2020-12-02 10:23

    This worked using System.Text.Json

    var options = new JsonSerializerOptions()
            {
                MaxDepth = 0,
                IgnoreNullValues = true,
                IgnoreReadOnlyProperties = true
            };
    

    Using options to serialize

    objstr = JsonSerializer.Serialize(obj,options);
    

提交回复
热议问题