EF 4.1是否支持IEnumerable集合进行映射? [英] Are IEnumerable collection supported in EF 4.1 for mapping?
问题描述
我记得这是以前版本的EF的问题。您不能将集合设为IEnumerable来公开您的方法。这是一个问题,因为我不希望有人直接访问该集合。
I remember this was a problem with previous version of EF. You couldnt make collections as IEnumerable for exposing your methods instead. This is a problem because i don't want someone to directly access the collection.
有关我在说什么的更多信息,请参见此...。为什么实体框架需要ICollection进行延迟加载?
See this for more info on what i am talking about... Why does the entity framework need an ICollection for lazy loading?
所以问题是.. EF 4.1现在是否支持IEnumerable属性用于映射关系?还是对此有解决方案?
So the question is.. are EF 4.1 now support IEnumerable property for mapping relationship ? or is there a solution to this ?
谢谢。
推荐答案
不,它不支持 IEnumerable
,因为EF内部需要通过调用 Add
进行分配和填充的集合。
No it doesn't support IEnumerable
because EF internally needs collection which can be assigned and filled by calling Add
.
这篇关于EF 4.1是否支持IEnumerable集合进行映射?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!