2

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.

See this for more info on what i am talking about... Why does the entity framework need an ICollection for lazy loading?

So the question is.. are EF 4.1 now support IEnumerable property for mapping relationship ? or is there a solution to this ?

Thanks.

Community
  • 1
  • 1
Rushino
  • 9,415
  • 16
  • 53
  • 93

1 Answers1

2

No it doesn't support IEnumerable because EF internally needs collection which can be assigned and filled by calling Add.

Ladislav Mrnka
  • 360,892
  • 59
  • 660
  • 670
  • 5
    Then is there a solution for the problem where you want to expose your own methods to access the collection instead of using the collection directly ? I believe it need to be public virtual.. but i don't want someone to directly add something to that collection. Why? because maybe i have some logic to be done during the process. – Rushino Sep 14 '11 at 15:25