Queryable.AsQueryable 메서드

정의

오버로드

AsQueryable(IEnumerable)

IEnumerableIQueryable로 변환합니다.Converts an IEnumerable to an IQueryable.

AsQueryable<TElement>(IEnumerable<TElement>)

제네릭 IEnumerable<T>을 제네릭 IQueryable<T>로 변환합니다.Converts a generic IEnumerable<T> to a generic IQueryable<T>.

AsQueryable(IEnumerable)

IEnumerableIQueryable로 변환합니다.Converts an IEnumerable to an IQueryable.

public:
[System::Runtime::CompilerServices::Extension]
 static System::Linq::IQueryable ^ AsQueryable(System::Collections::IEnumerable ^ source);
public static System.Linq.IQueryable AsQueryable (this System.Collections.IEnumerable source);
static member AsQueryable : System.Collections.IEnumerable -> System.Linq.IQueryable
<Extension()>
Public Function AsQueryable (source As IEnumerable) As IQueryable

매개 변수

source
IEnumerable

변환할 시퀀스입니다.A sequence to convert.

반환

입력 시퀀스를 나타내는 IQueryable입니다.An IQueryable that represents the input sequence.

예외

source가 일부 T에 대해 IEnumerable<T>을 구현하지 않는 경우source does not implement IEnumerable<T> for some T.

sourcenull입니다.source is null.

설명

경우 유형의 source 구현 IQueryable<T>, AsQueryable(IEnumerable) 직접 반환 합니다.If the type of source implements IQueryable<T>, AsQueryable(IEnumerable) returns it directly. 를 반환 합니다는 IQueryable<T> 동등한 쿼리 연산자 메서드를 호출 하 여 쿼리를 실행 하는 Enumerable 에 해당 하는 대신 Queryable합니다.Otherwise, it returns an IQueryable<T> that executes queries by calling the equivalent query operator methods in Enumerable instead of those in Queryable.

이 메서드는 가정 source 구현 IEnumerable<T> 일부 T합니다.This method assumes that source implements IEnumerable<T> for some T. 형식의 결과 런타임에 IQueryable<T> 동일한 T입니다.At runtime, the result is of type IQueryable<T> for the same T. 이 메서드는 형식의 정적으로 알 수 없는 경우 동적 시나리오에서 유용 T합니다.This method is useful in dynamic scenarios when you do not statically know the type of T.

AsQueryable<TElement>(IEnumerable<TElement>)

제네릭 IEnumerable<T>을 제네릭 IQueryable<T>로 변환합니다.Converts a generic IEnumerable<T> to a generic IQueryable<T>.

public:
generic <typename TElement>
[System::Runtime::CompilerServices::Extension]
 static System::Linq::IQueryable<TElement> ^ AsQueryable(System::Collections::Generic::IEnumerable<TElement> ^ source);
public static System.Linq.IQueryable<TElement> AsQueryable<TElement> (this System.Collections.Generic.IEnumerable<TElement> source);
static member AsQueryable : seq<'Element> -> System.Linq.IQueryable<'Element>
<Extension()>
Public Function AsQueryable(Of TElement) (source As IEnumerable(Of TElement)) As IQueryable(Of TElement)

형식 매개 변수

TElement

source 요소의 형식입니다.The type of the elements of source.

매개 변수

source
IEnumerable<TElement>

변환할 시퀀스입니다.A sequence to convert.

반환

IQueryable<TElement>

입력 시퀀스를 나타내는 IQueryable<T>입니다.An IQueryable<T> that represents the input sequence.

예외

sourcenull인 경우source is null.

예제

다음 코드 예제에 사용 하는 방법을 보여 줍니다 AsQueryable<TElement>(IEnumerable<TElement>) 변환 하는 IEnumerable<T>IQueryable<T>.The following code example demonstrates how to use AsQueryable<TElement>(IEnumerable<TElement>) to convert an IEnumerable<T> to an IQueryable<T>.

List<int> grades = new List<int> { 78, 92, 100, 37, 81 };

// Convert the List to an IQueryable<int>.
IQueryable<int> iqueryable = grades.AsQueryable();

// Get the Expression property of the IQueryable object.
System.Linq.Expressions.Expression expressionTree =
    iqueryable.Expression;

Console.WriteLine("The NodeType of the expression tree is: "
    + expressionTree.NodeType.ToString());
Console.WriteLine("The Type of the expression tree is: "
    + expressionTree.Type.Name);

/*
    This code produces the following output:

    The NodeType of the expression tree is: Constant
    The Type of the expression tree is: EnumerableQuery`1
*/
Dim grades As New List(Of Integer)(New Integer() {78, 92, 100, 37, 81})

' Convert the List to an IQueryable<int>.
Dim iqueryable As IQueryable(Of Integer) = grades.AsQueryable()

' Get the Expression property of the IQueryable object.
Dim expressionTree As System.Linq.Expressions.Expression = _
    iqueryable.Expression

MsgBox("The NodeType of the expression tree is: " _
    & expressionTree.NodeType.ToString())
MsgBox("The Type of the expression tree is: " _
    & expressionTree.Type.Name)

' This code produces the following output:
'
' The NodeType of the expression tree is: Constant
' The Type of the expression tree is: EnumerableQuery`1

설명

경우 유형의 source 구현 IQueryable<T>, AsQueryable<TElement>(IEnumerable<TElement>) 직접 반환 합니다.If the type of source implements IQueryable<T>, AsQueryable<TElement>(IEnumerable<TElement>) returns it directly. 를 반환 합니다는 IQueryable<T> 동등한 쿼리 연산자 메서드를 호출 하 여 쿼리를 실행 하는 Enumerable 에 해당 하는 대신 Queryable합니다.Otherwise, it returns an IQueryable<T> that executes queries by calling the equivalent query operator methods in Enumerable instead of those in Queryable.

적용 대상