在EF中可能有可变的导航属性 [英] Possible Have Changeable Navigation Property in EF

查看:125
本文介绍了在EF中可能有可变的导航属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



图像实体集

  class IMages {
public string FileName {set; get}


public Icollection< mychangeableEntity> mychangeableEntity {get; set;}

}

而不是

  IMages {

public virtual ICollection< Person>人{get; set;}
public virtual ICollection< Product>产品{get; set;}
public virtual ICollection< Gallery>画廊{get; set;}
}

表级中的一个解决方案是

  IMages(id,parentId,tableId,filename,size,...)
myTables(Id,Name);

获得我的表名的表

解决方案

AFAIK,这不能完成。



从数据库的角度来看,这将相当于具有多个外部关键限制几个不同的表,所有这些都必须在任何时候对列的任何值有效。



IMHO,这是不可能的甚至希望。


I want one image entity set for all enties that have many image like this:

Images Entity Set

class IMages {
public string FileName {set;get}


public Icollection<mychangeableEntity> mychangeableEntity{get;set;}

}

Instead of

IMages {

   public virtual ICollection<Person> Persons {get; set;}
   public virtual ICollection<Product> Products {get; set;}
   public virtual ICollection<Gallery> Galleries {get; set;}
}

one solution in table level is

IMages(id,parentId,tableId, filename,size,...)
myTables(Id,Name);

table that get my table's name

解决方案

AFAIK, this can't be done.

From a database point of view this would be equivalent to a column having several Foreign Key Constraints to several different tables, all having to be valid for any value of the column at anytime.

IMHO, that is not possible or even wishable.

这篇关于在EF中可能有可变的导航属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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