Queryable.AsQueryable<'TElement> Method (IEnumerable<'TElement>)
.NET Framework (current version)
Converts a generic IEnumerable<'T> to a generic IQueryable<'T>.
Assembly: System.Core (in System.Core.dll)
static member AsQueryable<'TElement> : source:IEnumerable<'TElement> -> IQueryable<'TElement>
Parameters
- 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.
Type Parameters
- TElement
The type of the elements of source.
| Exception | Condition |
|---|---|
| ArgumentNullException | 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>.
Universal Windows Platform
Available since 8
.NET Framework
Available since 3.5
Portable Class Library
Supported in: portable .NET platforms
Silverlight
Available since 2.0
Windows Phone Silverlight
Available since 7.1
Windows Phone
Available since 8.1
Available since 8
.NET Framework
Available since 3.5
Portable Class Library
Supported in: portable .NET platforms
Silverlight
Available since 2.0
Windows Phone Silverlight
Available since 7.1
Windows Phone
Available since 8.1
Show: