【发布时间】:2014-07-02 11:51:24
【问题描述】:
我有这样的事情:
public class Product{
[some properties]
public ICollection<ProductImage> ProductImages {set;get;}
}
public class ProductImages {
string fileName,
string size, ...
public Product Product{set;get}
}
public class Poeple{
[some properties]
public virtual ICollection<PersonImage> PersonImages {set;get;}
}
public class PersonImages{
string fileName, string size, ... public Person Person{set;get}
}
... 和其他实体有一个更多的表作为自己的图像的孩子;
我想从所有 ProductImages、PersonImages 和 ... 中获取摘要,并获取一个实体(表),如下所示:
public Images {
int size{set;get;} ,
string FileName{set; get;}, ... othes prop
}
但是将图像表的每条记录引用到其父级的最佳方法是什么
枚举类型作为图像实体的属性是否是一个很好的解决方案枚举类型,例如:
Enum BelongTo
{
ProductTable,
GalleryTabl,
PersonTable,
}
public Images {
BelongTo belong {get;set;}
int size {set; get;}
string FileName {set; get;}
}
使用枚举我不能在父母和孩子之间拥有导航属性 什么是关注 DDD 的便捷解决方案
【问题讨论】:
-
您可以为此在实体框架中使用复杂类型
-
嗨@Aju Mon 我知道它适合一些像地址这样的道具。你是什么意思?你能解释更多吗?
标签: c# .net entity-framework entity domain-driven-design