This is a migrated thread and some comments may be shown as answers.

[Solved] Still getting circular reference when using var type

1 Answer 37 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Jon Baron
Top achievements
Rank 1
Jon Baron asked on 14 Oct 2011, 10:12 PM
Hi all,

I am using this demo as an example:
http://www.telerik.com/community/code-library/aspnet-mvc/grid/using-dropdownlist-to-edit-a-foreign-key-column.aspx


The problem I am having is when trying to bind the query:

[GridAction]
        public ActionResult Select()
        {
            var products = new Models.NorthwindEntities().Products;
 
            var data = from p in products
                           select new // Use anonymous type to avoid JSON serialization exceptions due to circular object references. Also serialize only the required properties (for performance)
                           {
                               p.Category,
                               p.ProductID,
                               p.ProductName,
                               p.CategoryID
                           };
 
            return View(new GridModel(data));
        }

I'm not sure how p.Category, does not give a circular reference in this example?

I have an edmx with a table that has FK's to 3 other tables, when I try and do something simliar like 'p.Category', I receive a circular reference on any of the 3 tables. 

My intent is to display this in a datagrid, so I tried selecting 'p.Category.CategoryName' and then binding to column.bound(t => t.Category.CategoryName) but the busy indicator
on the grid just continuously spins.

Why do I receive a circular reference when attempting the same as above and/or why is the exact property not coming across?

Thanks!

1 Answer, 1 is accepted

Sort by
0
Jon Baron
Top achievements
Rank 1
answered on 15 Oct 2011, 05:14 PM
Tags
Grid
Asked by
Jon Baron
Top achievements
Rank 1
Answers by
Jon Baron
Top achievements
Rank 1
Share this question
or