是否可以使用 EF4.x 映射值对象的集合?
我找不到映射值对象集合的方法,可能吗?
public class AnEntity
{
public int Id {get;set;}
public ICollection<Guid> Values {get;set;} // <-- this
}
谢谢, E.
I can't find a way to map a value object collection, is it possible?
public class AnEntity
{
public int Id {get;set;}
public ICollection<Guid> Values {get;set;} // <-- this
}
Thanks,
E.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
因为这是不可能的。您只能映射实体的集合(带有键的类)。您可以通过使用特殊实体并公开第二个属性来解决此问题,该属性将为您提供投影:
如果您预计集合会很小,您也可以使用单个字符串字段而不是相关集合并使用
String.Split
,String.Join
提供集合模拟。Because it is not possible. You can map only collection of entities (classes with key). You can solve this by using special entity and exposing second property which will provide projection for you:
If you expect that collection will be small you can also use single string field instead of related collection and use
String.Split
,String.Join
to provide emulation of collection.