Telerik.Web.Mvc.Extensions.QueryableExtensions.ToIList C# (CSharp) Method

ToIList() public static method

Creates a IList{T} from an IQueryable where T is IQueryable.ElementType.
/// is null. ///
public static ToIList ( this source ) : IList
source this /// The to create a from. ///
return IList
        public static IList ToIList(this IQueryable source)
        {
            if (source == null) throw new ArgumentNullException("source");

            var list = (IList)Activator.CreateInstance(typeof(List<>).MakeGenericType(source.ElementType));

            foreach (var item in source)
            {
                list.Add(item);
            }

            return list;
        }