Queryable.AsQueryable Method (IEnumerable)


The .NET API Reference documentation has a new home. Visit the .NET API Browser on docs.microsoft.com to see the new experience.

Converts an IEnumerable to an IQueryable.

Namespace:   System.Linq
Assembly:  System.Core (in System.Core.dll)

Public Shared Function AsQueryable (
	source As IEnumerable
) As IQueryable


Type: System.Collections.IEnumerable

A sequence to convert.

Return Value

Type: System.Linq.IQueryable

An IQueryable that represents the input sequence.

Exception Condition

source does not implement IEnumerable(Of T) for some T.


source is null.

If the type of source implements IQueryable(Of T), AsQueryable(IEnumerable) returns it directly. Otherwise, it returns an IQueryable(Of T) that executes queries by calling the equivalent query operator methods in Enumerable instead of those in Queryable.

This method assumes that source implements IEnumerable(Of T) for some T. At runtime, the result is of type IQueryable(Of T) for the same T. This method is useful in dynamic scenarios when you do not statically know the type of T.

Universal Windows Platform
Available since 8
.NET Framework
Available since 3.5
Portable Class Library
Supported in: portable .NET platforms
Available since 2.0
Windows Phone Silverlight
Available since 7.1
Windows Phone
Available since 8.1
Return to top