views:

37

answers:

1

HI

I am using telerik mvc grid with ajax binding

<%Html.Telerik().Grid<UserManagement.Models.setupEmployee>()
        .Name("setupEmployees")
            .DataBinding(dataBinding => dataBinding
                //Ajax binding 
                .Ajax()
                //The action method which will return JSON 
                       .Select("_AjaxBindingEmployee", "UM")

            ).
            Columns(colums =>
            {
                colums.Bound(o => o.EmployeeName).Title("Name");
                colums.Bound(o => o.setupDesignation.Title).Title("Designation");
                colums.Bound(o => o.Gender);
                colums.Bound(o => o.DOB);
                colums.Bound(o => o.EmployeeID).Format( 
              %><%Html.ActionLink("Edit", "Edit", new { Id = "{0}" }).ToString()).Encoded(false);
            })
        .Pageable()
        .Sortable()
        .Filterable()
        .PrefixUrlParameters(false)        
        .Render(); 
  %> 

when i try to populate the grid with

return db.setupEmployees 

i get the following error

A circular reference was detected while serializing an object of type. As i have relationship of this table with other tables. To avoid this i may have two options either i use viewmodel or disable the relationships which is not possible. Any other sugession from your side

Regards

A: 

The associations created in the LinqToSql designer are under your control.

You can remove them (does not change the database).

You can edit them so they generate single sided properties instead of dual facing properties (does not change the database).

You can edit them so they generate no properties at all (does not change database).

The designer's file is a mapping file, it does not change the database.

David B
thanks for reply, Yes it is a mapping file and does not change the database but on i need to exploit the collections at the same time. please correct me if i am wrong i think if i remove the association if will not be able to do "o => o.setupDesignation.Title" in my above mentioned code
Tassadaque
You can set them to generate only the parent property or only the child property. That way they aren't circular.
David B