圆形参考 - 的LINQ to SQL [英] Circular Reference- LINQ to SQL

查看:122
本文介绍了圆形参考 - 的LINQ to SQL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

HI

我使用Telerik的MVC电网与阿贾克斯结合

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 

我收到以下错误

而序列化类型的对象时检测到循环引用。正如我与其他表此表的关系。
为了避免这种情况我可以有两个选择要么我使用视图模型或禁用这是不可能的关系。从你身边的任何其他sugession

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

问候

推荐答案

在LinqToSql设计器创建的关联是你的控制之下。

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.

这篇关于圆形参考 - 的LINQ to SQL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆