Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to convert EntityCollection<T> to List<T>

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();
like image 964
Darcy Avatar asked Oct 03 '11 21:10

Darcy


1 Answers

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>.

like image 156
Darin Dimitrov Avatar answered Nov 14 '22 12:11

Darin Dimitrov