I'm new to asp.net MVC4 and I have an issue with the serialization of an entire Dataset.
When I return this Dataset, eg. db.Prestations.ToList()
and call my endpoint in Postman, the request takes much time and doesn't respond.
If I put the result of db.Prestations.ToList()
in a variable and I throw an exception after, I get the exception in my request.
So it's seems to be a serialization issue, like the data returned are too big.
My question is how do I remove sub-objects I don't need in my Prestations
?
Here is my model, and I don't want it to return the three Hashsets, how can I do that ?
namespace Uphair.EfModel
{
using System;
using System.Collections.Generic;
public partial class Prestation
{
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")]
public Prestation()
{
this.PartenairePrestations = new HashSet<PartenairePrestation>();
this.PrixDureeOptions = new HashSet<PrixDureeOption>();
this.LigneReservations = new HashSet<LigneReservation>();
}
public int IdPrestation { get; set; }
public string NomPrestation { get; set; }
public int Categorie { get; set; }
public Nullable<int> CoifEsthe { get; set; }
public Nullable<int> IdPrestationCategorie { get; set; }
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
public virtual ICollection<PartenairePrestation> PartenairePrestations { get; set; }
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
public virtual ICollection<PrixDureeOption> PrixDureeOptions { get; set; }
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
public virtual ICollection<LigneReservation> LigneReservations { get; set; }
public virtual PrestationCategorie PrestationCategorie { get; set; }
}
}
Thanks to anyone who will take the time to help me :)