Queryable.AsQueryable<'TElement> Method (IEnumerable<'TElement>)


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

Converts a generic IEnumerable<'T> to a generic IQueryable<'T>.

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

static member AsQueryable<'TElement> : 
        source:IEnumerable<'TElement> -> IQueryable<'TElement>


Type: System.Collections.Generic.IEnumerable<'TElement>

A sequence to convert.

Return Value

Type: System.Linq.IQueryable<'TElement>

An IQueryable<'T> that represents the input sequence.

Type Parameters


The type of the elements of source.

Exception Condition

source is null.

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

The following code example demonstrates how to use AsQueryable<'TElement>(IEnumerable<'TElement>) to convert an IEnumerable<'T> to an IQueryable<'T>.

No code example is currently available or this language may not be supported.

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