JSonIgnore M2M joint

This commit is contained in:
Ruidy Nemausat 2020-02-28 13:16:16 +01:00
parent e4fe81a45c
commit 1af2d95e7a
2 changed files with 9 additions and 7 deletions

View file

@ -2,6 +2,7 @@ using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text.Json.Serialization;
namespace TicketManager.Models
{
@ -39,6 +40,7 @@ namespace TicketManager.Models
[Display(Name = "Avatar")]
public string Picture { get; set; }
[JsonIgnore]
public List<Assignment> Assignments { get; set; } = new List<Assignment>();
[Display(Name = "Activity")]

View file

@ -14,7 +14,7 @@ using Microsoft.EntityFrameworkCore;
using Microsoft.OpenApi.Models;
using Microsoft.AspNetCore.Mvc.NewtonsoftJson;
using Microsoft.AspNetCore.Authentication.JwtBearer;
using Newtonsoft.Json;
// using Newtonsoft.Json;
using TicketManager.Data;
[assembly: ApiController]
@ -48,12 +48,12 @@ namespace TicketManager
options.Audience = "https://localhost:5001/api/V1/";
});
services.AddControllers()
.AddNewtonsoftJson(options =>
{
options.SerializerSettings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore; // avoid cycle ref errors
}
);
services.AddControllers();
// .AddNewtonsoftJson(options =>
// {
// options.SerializerSettings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore; // avoid cycle ref errors
// }
// );
services.AddSpaStaticFiles(configuration =>
{