What version of .NET are you using? If it's .NET 3.5, I just call ToArray() and do it with it.
If you have only universal IEnumerable, do something like this:
IEnumerable query = ...; MyEntityType[] array = query.Cast<MyEntityType>().ToArray();
If you do not know the type inside this method, but the methods that call it know it, make this method general and try the following:
public static void T[] PerformQuery<T>() { IEnumerable query = ...; T[] array = query.Cast<T>().ToArray(); return array; }
Jon Skeet Nov 06 '08 at 13:34 2008-11-06 13:34
source share