Bonjour,
J'ai créé une classe hiérarchique Société
J'utilise auto mapper et lorsque j'invoque la commande map, j'ai cette exception :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10 public class Societe { public string Id { get; set; } public string Name { get; set; } public ICollection<Societe> Filiales { get; set; } public ICollection<AppSociete> AppsSociete { get; set; } [JsonIgnore] //<-- Notez le JsonIgnore public Societe SocieteParente{ get; set; } }
Newtonsoft.Json.JsonSerializationException*: 'Self referencing loop detected for property 'SocieteParente' with type 'Data.Entities.Societe'. Path 'AppsSocietes[0]'.'
Ma recherche Internet m'a permis de trouver : https://stackoverflow.com/questions/...ected-for-type
Dans ma config j'ai
Je ne comprends pas ce qu'il se passe.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7 services.AddMvc() .AddJsonOptions(options => { options.SerializerSettings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore; //options.SerializerSettings.PreserveReferencesHandling = PreserveReferencesHandling.Objects; <- J'ai essayé avec et sans, même résultat. });
Pourriez-vous m'aider ?
Merci
Partager