Queryable.AsQueryable Method (IEnumerable)

[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]

Converts an IEnumerable to an IQueryable.

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


<ExtensionAttribute> _
Public Shared Function AsQueryable ( _
    source As IEnumerable _
) As IQueryable
public static IQueryable AsQueryable(
    this IEnumerable source


Return Value

Type: System.Linq..::.IQueryable
An IQueryable that represents the input sequence.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type IEnumerable. When you use instance method syntax to call this method, omit the first parameter.


Exception Condition

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


source is nullNothingnullptra null reference (Nothing in Visual Basic).


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.

Version Information

Windows Phone OS

Supported in: 8.1, 8.0, 7.1


Windows Phone

See Also


Queryable Class

AsQueryable Overload

System.Linq Namespace