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

View file

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