System.Linq.Queryable.AsQueryable Method

Converts an IEnumerable to an System.Linq.IQueryable.

Syntax

public static IQueryable AsQueryable (this IEnumerable source)

Parameters

source
A sequence to convert.

Returns

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

Remarks

If the type of source implements System.Linq.IQueryable`1, Queryable.AsQueryable(IEnumerable) returns it directly. Otherwise, it returns an System.Linq.IQueryable`1 that executes queries by calling the equivalent query operator methods in System.Linq.Enumerable instead of those in System.Linq.Queryable.

This method assumes that source implements IEnumerable`1 for some T. At runtime, the result is of type System.Linq.IQueryable`1 for the same T. This method is useful in dynamic scenarios when you do not statically know the type of T.

Requirements

Namespace: System.Linq
Assembly: System.Core (in System.Core.dll)
Assembly Versions: 3.5.0.0, 4.0.0.0