Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

Queryable.AsQueryable(TElement) Method (IEnumerable(TElement))

Converts a generic IEnumerable(T) to a generic IQueryable(T).

Namespace:  System.Linq
Assemblies:   System.Linq.Queryable (in System.Linq.Queryable.dll)
  System.Core (in System.Core.dll)

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

Type Parameters


The type of the elements of source.


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.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type IEnumerable(TElement). When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).


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

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.

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Portable Class Library

Supported in: Portable Class Library

Supported in: Windows Phone 8.1

Supported in: Windows Phone Silverlight 8.1

Supported in: Windows Phone Silverlight 8
© 2015 Microsoft