Circular Reference- LINQ to SQL
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 dete开发者_高级运维cted 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
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.
精彩评论