one to many relationship

2 posts, 0 answers
  1. Ahmad
    Ahmad avatar
    2 posts
    Member since:
    May 2012

    Posted 03 Sep 2013 Link to this post

    I have two model.
    When I want to display a list of Product in grid, if PurchaseInvoiceDetail have records, Product grid show empty list,
    and when i delete PurchaseInvoiceDetail records, Product's grid display list of product.
    (I use Editing_Popup grid)
    public class Product
            public int ProductId { get; set; }       
            public string Name { get; set; }
            public int Number { get; set; }
            public virtual ICollection<PurchaseInvoiceDetail> PurchaseInvoiceDetail { get; set; }
    public class PurchaseInvoiceDetail
            public int PurchaseInvoiceDetailId { get; set; }
            public int Number { get; set; }
            public decimal PurchasePrice { get; set; }
            //Navigation Properties
            public int ProductId { get; set; }
            public virtual Product Product { get; set; }
  2. Dimiter Madjarov
    Dimiter Madjarov avatar
    2272 posts

    Posted 05 Sep 2013 Link to this post

    Hi Ahmad,

    The most probable reason for the issue is that a circular reference was detected when serializing th objects. It is caused because both of the classes have properties that reference to each other, which the JavaScript serialize cannot handle. As a resolution for this issue you should extract a ViewModel of the data, which excludes those properties. You could take a look at the following documentation page for additional details.


    Dimiter Madjarov
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Back to Top