Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/275.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 为什么从EntityObject继承?_C#_Asp.net_Entity Framework_Devart - Fatal编程技术网

C# 为什么从EntityObject继承?

C# 为什么从EntityObject继承?,c#,asp.net,entity-framework,devart,C#,Asp.net,Entity Framework,Devart,我正在使用“Devart Entity Developer”为实体框架的数据库建模。 为什么我的类继承自EntityObject 我在任何实体框架文档中都看不到这是必需的,也看不到这是最佳实践 这是一个生成类的示例: //------------------------------------------------------------------------------ // This is auto-generated code. //--------------------------

我正在使用“Devart Entity Developer”为实体框架的数据库建模。 为什么我的类继承自EntityObject

我在任何实体框架文档中都看不到这是必需的,也看不到这是最佳实践

这是一个生成类的示例:

//------------------------------------------------------------------------------
// This is auto-generated code.
//------------------------------------------------------------------------------
// This code was generated by Devart Entity Developer tool using Entity Framework EntityObject template.
// Code is generated on: 20.03.2016 12.01.45
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
//------------------------------------------------------------------------------

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.Common;
using System.Linq;
using System.Runtime.Serialization;
using System.Xml.Serialization;
using System.Data.Entity.Core.EntityClient;
using System.Data.Entity.Core.Metadata.Edm;
using System.Data.Entity.Core.Objects;
using System.Data.Entity.Core.Objects.DataClasses;

namespace Stackoverflow.Example
{

    /// <summary>
    /// There are no comments for Stackoverflow.Example.Purchase in the schema.
    /// </summary>
    /// <KeyProperties>
    /// PurchaseId
    /// </KeyProperties>
    [EdmEntityTypeAttribute(NamespaceName="Donate.Models.Entities", Name="Purchase")]
    [Serializable()]
    [DataContractAttribute(IsReference=true)]
    public partial class Purchase : EntityObject    {
        #region Factory Method

        /// <summary>
        /// Create a new Purchase object.
        /// </summary>
        /// <param name="purchaseId">Initial value of PurchaseId.</param>
        public static Purchase CreatePurchase(int purchaseId)
        {
            Purchase purchase = new Purchase();
            purchase.PurchaseId = purchaseId;
            return purchase;
        }

        #endregion

        #region Properties

        /// <summary>
        /// There are no comments for PurchaseId in the schema.
        /// </summary>
        [EdmScalarPropertyAttribute(EntityKeyProperty=true, IsNullable=false)]
        [DataMemberAttribute()]
        [System.ComponentModel.DataAnnotations.Key]
        [System.ComponentModel.DataAnnotations.Required()]
        public int PurchaseId
        {
            get
            {
                int value = _PurchaseId;
                OnGetPurchaseId(ref value);
                return value;
            }
            private set
            {
                if (_PurchaseId != value)
                {
                  OnPurchaseIdChanging(ref value);
                  ReportPropertyChanging("PurchaseId");
                  _PurchaseId = StructuralObject.SetValidValue(value);
                  ReportPropertyChanged("PurchaseId");
                  OnPurchaseIdChanged();
              }
            }
        }
        private int _PurchaseId;
        partial void OnGetPurchaseId(ref int value);
        partial void OnPurchaseIdChanging(ref int value);
        partial void OnPurchaseIdChanged();

        #endregion
    }

}
//------------------------------------------------------------------------------
//这是自动生成的代码。
//------------------------------------------------------------------------------
//此代码由Devart Entity Developer工具使用实体框架EntityObject模板生成。
//代码生成日期:20.03.2016 12.01.45
//
//对此文件的更改可能会导致不正确的行为,如果
//重新生成代码。
//------------------------------------------------------------------------------
使用制度;
使用System.Collections.Generic;
使用系统组件模型;
使用系统数据;
使用System.Data.Common;
使用System.Linq;
使用System.Runtime.Serialization;
使用System.Xml.Serialization;
使用System.Data.Entity.Core.EntityClient;
使用System.Data.Entity.Core.Metadata.Edm;
使用System.Data.Entity.Core.Objects;
使用System.Data.Entity.Core.Objects.DataClass;
命名空间Stackoverflow.Example
{
/// 
///架构中没有Stackoverflow.Example.Purchase的注释。
/// 
/// 
///采购ID
/// 
[EdmEntityTypeAttribute(NamespaceName=“捐赠.模型.实体”,Name=“购买”)]
[可序列化()]
[DataContractAttribute(IsReference=true)]
公共部分类购买:EntityObject{
#区域工厂法
/// 
///创建一个新的购买对象。
/// 
///PurchaseId的初始值。
公共静态购买CreatePurchase(int purchaseId)
{
采购=新采购();
PurchaseId=PurchaseId;
退货;
}
#端区
#区域属性
/// 
///架构中没有PurchaseId的注释。
/// 
[EdmScalarPropertyAttribute(EntityKeyProperty=true,IsNullable=false)]
[DataMemberAttribute()]
[System.ComponentModel.DataAnnotations.Key]
[System.ComponentModel.DataAnnotations.Required()]
公共int PurchaseId
{
得到
{
int值=_PurchaseId;
OnGetPurchaseId(参考值);
返回值;
}
专用设备
{
如果(_PurchaseId!=值)
{
OnPurchaseIdChanging(参考值);
ReportPropertyChange(“PurchaseId”);
_PurchaseId=StructuralObject.SetValidValue(值);
ReportPropertyChanged(“PurchaseId”);
OnPurchaseIdChanged();
}
}
}
私人国际采购ID;
部分无效OnGetPurchaseId(参考int值);
PurchaseIDChanged部分无效(参考int值);
PurchaseIDChanged()上的部分无效;
#端区
}
}

这里有很多有用的想法,但它仍然没有说明继承EntityObject有什么好处。在EF的旧版本中,模型首先意味着继承自
EntityObject
@Henkholtman EF6