Hi,
I need show a grid in a page, and the deatils in other page. The main load works fine but when I load the details I get a circular reference error.
I've this classes:
public partial class Incidencia
{
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")]
public Incidencia()
{
IncidenciaMes = new HashSet<IncidenciaMes>();
}
public int ID { get; set; }
[Column(TypeName = "date")]
public DateTime Fecha { get; set; }
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
public virtual ICollection<IncidenciaMes> IncidenciaMes { get; set; }
}
public partial class IncidenciaMes
{
public int ID { get; set; }
public int IDIncidencia { get; set; }
[Column(TypeName = "date")]
public DateTime Fecha { get; set; }
public string Descripcion { get; set; }
public virtual Incidencia Incidencia { get; set; }
} For load the main grid: Incidencias (it works fine)
public List<Incidencia> GetIncidencias()
{
return new GNC_Model().Incidencia.ToList();
}For load the incidencia's details
public Incidencia GetIncidencia(int id)
{
return new GNC_Model().Incidencia.Where(p => p.IDIncidencia == id).First() as Incidencia;
}The context configuration
public partial class GNC_Model : DbContext
{
public GNC_Model()
: base("name=DataModel")
{
this.Configuration.ProxyCreationEnabled = false;
this.Configuration.LazyLoadingEnabled = false;
}
}The view
@model Incidencia
@(Html.EJ().Grid<IncidenciaMes>("gridIncidenciaMes")
.Datasource((IEnumerable<object>)Model.IncidenciaMes.ToList())
.Columns(c =>
{
c.Field("ID").Add();
c.Field("Fecha").Add();
})
)