ObjectContext实例已被释放,不能再用于需要连接的操作

时间:2011-05-30 07:16:43

标签: asp.net asp.net-mvc-2 linq-to-entities

我的edmx设计器文件中包含此代码:

    #region Navigation Properties

    /// <summary>
    /// No Metadata Documentation available.
    /// </summary>
    [XmlIgnoreAttribute()]
    [SoapIgnoreAttribute()]
    [DataMemberAttribute()]
    [EdmRelationshipNavigationPropertyAttribute("EnviroModel", "FK_Whiteout_Field1", "Field")]
    public Field Field
    {
        get
        {
            **return ((IEntityWithRelationships)this).RelationshipManager.GetRelatedReference<Field>("EnviroModel.FK_Whiteout_Field1", "Field").Value;**
        }
        set
        {
            ((IEntityWithRelationships)this).RelationshipManager.GetRelatedReference<Field>("EnviroModel.FK_Whiteout_Field1", "Field").Value = value;
        }
    }

我在获取部分时遇到以下错误:

The ObjectContext instance has been disposed and can no longer be used for operations that require a connection.

0 个答案:

没有答案