We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

Circular reference loading details

Thread ID:

Created:

Updated:

Platform:

Replies:

126365 Oct 11,2016 03:47 AM Oct 17,2016 12:23 AM ASP.NET MVC 3
loading
Tags: Grid
Manolo
Asked On October 11, 2016 03:47 AM

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();
                    })
                )


                


Venkatesh Ayothi Raman [Syncfusion]
Replied On October 12, 2016 08:51 AM

Hi Manolo, 

Thank you for contacting Syncfusion support. 

We have already discussed this and created a knowledge base documentation. Please refer to the documents from following link, 
And we suggest you to use view model to transfer data between a controller and a view

Regards, 
Venkatesh Ayothiraman. 


Manolo
Replied On October 14, 2016 08:06 AM

Ok, thanks!

Venkatesh Ayothi Raman [Syncfusion]
Replied On October 17, 2016 12:23 AM

Hi Manolo, 

Thanks for the update. 

We are happy to hear that your requirement is achieved. 

Thanks, 
Venkatesh Ayothiraman. 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;