EntityCollectionT> to ListT> conversion

.net c# entity-framework

Question

I'm trying to convert an EntityCollection to a List but I don't see a way to do this.

Something like:

List<myEntity> entityList = myEntityCollection.ToList();
1
9
10/3/2011 9:23:52 PM

Accepted Answer

Did you try:

 List<myEntity> entityList = new List<myEntity>(myEntityCollection);

And by the way if you import the System.Linq namespace in order to bring the .ToList() extension method into scope, there's no reason why:

List<myEntity> entityList = myEntityCollection.ToList();

wouldn't work as EntityCollection<T> implements IEnumerable<T>.

19
10/3/2011 9:45:59 PM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow