Click to Rate and Give Feedback
MSDN
MSDN Library
.NET Development
.NET Framework 3.5
Queryable Class
Queryable Methods
 AsQueryable Method (IEnumerable)
Collapse All/Expand All Collapse All
This page is specific to
Microsoft Visual Studio 2008/.NET Framework 3.5

Other versions are also available for the following:
.NET Framework Class Library
Queryable..::.AsQueryable Method (IEnumerable)

Converts an IEnumerable to an IQueryable.

Namespace:  System.Linq
Assembly:  System.Core (in System.Core.dll)
Visual Basic (Declaration)
<ExtensionAttribute> _
Public Shared Function AsQueryable ( _
    source As IEnumerable _
) As IQueryable
Visual Basic (Usage)
Dim source As IEnumerable
Dim returnValue As IQueryable

returnValue = source.AsQueryable()
C#
public static IQueryable AsQueryable(
    this IEnumerable source
)
Visual C++
[ExtensionAttribute]
public:
static IQueryable^ AsQueryable(
    IEnumerable^ source
)
JScript
public static function AsQueryable(
    source : IEnumerable
) : IQueryable

Parameters

source
Type: System.Collections..::.IEnumerable
A sequence to convert.

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. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).
ExceptionCondition
ArgumentException

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

ArgumentNullException

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.

Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5
Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks | Privacy Statement
Page view tracker