Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/320.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# 在C中映射IS-A关系的正确方法#_C#_Sql_Orm - Fatal编程技术网

C# 在C中映射IS-A关系的正确方法#

C# 在C中映射IS-A关系的正确方法#,c#,sql,orm,C#,Sql,Orm,让我们想象一个简单的IS-a关系,如以下示例: create table EntityAbstract( IDEntityAbstract int identity primary key, Name nvarchar(50) not null, ) create table OneOfConcreteEntity( EntityAbstract int, constraint PK_Image primary key (EntityAbstract), constrai

让我们想象一个简单的IS-a关系,如以下示例:

create table EntityAbstract(
  IDEntityAbstract int identity primary key,
  Name nvarchar(50) not null,
)


create table OneOfConcreteEntity(
  EntityAbstract int,
  constraint PK_Image primary key (EntityAbstract),
  constraint FK_Image foreign key (EntityAbstract) references EntityAbstract(IDEntityAbstract)  
)
当我从数据库映射实体时,我应该使它们成为独立的唯一对象,还是应该使具体类从抽象实体扩展而来

e、 g:

最好的选择是什么?考虑到不止一个具体实体和更复杂的实体。

有几个实体涉及IS-A关系,通常这正是继承的目的

  public class EntityAbstract
    {
        public int EntityAbstractID { get; set; }
        public string Name { get; set; }
        public EntityAbstract(int entityID, string name)
        {
            this.EntityAbstractID = entityID;
            this.Name = name;
        }
    }

   public class OneOfConcreatEntity : EntityAbstract
    {
        public OneOfConcreatEntity(int entityID, string name) : base(entityID, name){ }
    }