Queryable.AsQueryable Methode

Definition

Überlädt

Name Beschreibung
AsQueryable(IEnumerable)

Wandelt eine IEnumerable in eine IQueryableum.

AsQueryable<TElement>(IEnumerable<TElement>)

Wandelt eine generische IEnumerable<T> in eine generische IQueryable<T>um.

AsQueryable(IEnumerable)

Quelle:
Queryable.cs
Quelle:
Queryable.cs
Quelle:
Queryable.cs
Quelle:
Queryable.cs
Quelle:
Queryable.cs

Wandelt eine IEnumerable in eine IQueryableum.

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);
[System.Diagnostics.CodeAnalysis.RequiresDynamicCode("Enumerating in-memory collections as IQueryable can require creating new generic types or methods, which requires creating code at runtime. This may not work when AOT compiling.")]
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Enumerating in-memory collections as IQueryable can require unreferenced code because expressions referencing IQueryable extension methods can get rebound to IEnumerable extension methods. The IEnumerable extension methods could be trimmed causing the application to fail at runtime.")]
public static System.Linq.IQueryable AsQueryable(this System.Collections.IEnumerable source);
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Enumerating in-memory collections as IQueryable can require unreferenced code because expressions referencing IQueryable extension methods can get rebound to IEnumerable extension methods. The IEnumerable extension methods could be trimmed causing the application to fail at runtime.")]
public static System.Linq.IQueryable AsQueryable(this System.Collections.IEnumerable source);
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Enumerating in-memory collections as IQueryable can require unreferenced code because expressions referencing IQueryable extension methods can get rebound to IEnumerable extension methods. The IEnumerable extension methods could be trimmed causing the application to fail at runtime.")]
[System.Diagnostics.CodeAnalysis.RequiresDynamicCode("Enumerating collections as IQueryable can require creating new generic types or methods, which requires creating code at runtime. This may not work when AOT compiling.")]
public static System.Linq.IQueryable AsQueryable(this System.Collections.IEnumerable source);
static member AsQueryable : System.Collections.IEnumerable -> System.Linq.IQueryable
[<System.Diagnostics.CodeAnalysis.RequiresDynamicCode("Enumerating in-memory collections as IQueryable can require creating new generic types or methods, which requires creating code at runtime. This may not work when AOT compiling.")>]
[<System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Enumerating in-memory collections as IQueryable can require unreferenced code because expressions referencing IQueryable extension methods can get rebound to IEnumerable extension methods. The IEnumerable extension methods could be trimmed causing the application to fail at runtime.")>]
static member AsQueryable : System.Collections.IEnumerable -> System.Linq.IQueryable
[<System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Enumerating in-memory collections as IQueryable can require unreferenced code because expressions referencing IQueryable extension methods can get rebound to IEnumerable extension methods. The IEnumerable extension methods could be trimmed causing the application to fail at runtime.")>]
static member AsQueryable : System.Collections.IEnumerable -> System.Linq.IQueryable
[<System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Enumerating in-memory collections as IQueryable can require unreferenced code because expressions referencing IQueryable extension methods can get rebound to IEnumerable extension methods. The IEnumerable extension methods could be trimmed causing the application to fail at runtime.")>]
[<System.Diagnostics.CodeAnalysis.RequiresDynamicCode("Enumerating collections as IQueryable can require creating new generic types or methods, which requires creating code at runtime. This may not work when AOT compiling.")>]
static member AsQueryable : System.Collections.IEnumerable -> System.Linq.IQueryable
<Extension()>
Public Function AsQueryable (source As IEnumerable) As IQueryable

Parameter

source
IEnumerable

Eine zu konvertierende Sequenz.

Gibt zurück

Ein IQueryable Wert, der die Eingabesequenz darstellt.

Attribute

Ausnahmen

sourcewird für einige IEnumerable<T>nicht implementiertT.

source ist null.

Hinweise

Wenn der Typ der source Implementierungen erfolgt IQueryable<T>, wird AsQueryable(IEnumerable) sie direkt zurückgegeben. Andernfalls wird eine IQueryable<T> Abfrage zurückgegeben, die Abfragen ausführt, indem die entsprechenden Abfrageoperatormethoden Enumerable anstelle dieser in Queryableaufgerufen werden.

Bei dieser Methode wird davon ausgegangen, dass source für einige IEnumerable<T>implementiert T wird. Zur Laufzeit ist das Ergebnis vom Typ IQueryable<T> für dasselbe T. Diese Methode ist in dynamischen Szenarien nützlich, wenn Sie den Typ von T. nicht statisch kennen.

Gilt für:

AsQueryable<TElement>(IEnumerable<TElement>)

Quelle:
Queryable.cs
Quelle:
Queryable.cs
Quelle:
Queryable.cs
Quelle:
Queryable.cs
Quelle:
Queryable.cs

Wandelt eine generische IEnumerable<T> in eine generische IQueryable<T>um.

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);
[System.Diagnostics.CodeAnalysis.RequiresDynamicCode("Enumerating in-memory collections as IQueryable can require creating new generic types or methods, which requires creating code at runtime. This may not work when AOT compiling.")]
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Enumerating in-memory collections as IQueryable can require unreferenced code because expressions referencing IQueryable extension methods can get rebound to IEnumerable extension methods. The IEnumerable extension methods could be trimmed causing the application to fail at runtime.")]
public static System.Linq.IQueryable<TElement> AsQueryable<TElement>(this System.Collections.Generic.IEnumerable<TElement> source);
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Enumerating in-memory collections as IQueryable can require unreferenced code because expressions referencing IQueryable extension methods can get rebound to IEnumerable extension methods. The IEnumerable extension methods could be trimmed causing the application to fail at runtime.")]
public static System.Linq.IQueryable<TElement> AsQueryable<TElement>(this System.Collections.Generic.IEnumerable<TElement> source);
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Enumerating in-memory collections as IQueryable can require unreferenced code because expressions referencing IQueryable extension methods can get rebound to IEnumerable extension methods. The IEnumerable extension methods could be trimmed causing the application to fail at runtime.")]
[System.Diagnostics.CodeAnalysis.RequiresDynamicCode("Enumerating collections as IQueryable can require creating new generic types or methods, which requires creating code at runtime. This may not work when AOT compiling.")]
public static System.Linq.IQueryable<TElement> AsQueryable<TElement>(this System.Collections.Generic.IEnumerable<TElement> source);
static member AsQueryable : seq<'Element> -> System.Linq.IQueryable<'Element>
[<System.Diagnostics.CodeAnalysis.RequiresDynamicCode("Enumerating in-memory collections as IQueryable can require creating new generic types or methods, which requires creating code at runtime. This may not work when AOT compiling.")>]
[<System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Enumerating in-memory collections as IQueryable can require unreferenced code because expressions referencing IQueryable extension methods can get rebound to IEnumerable extension methods. The IEnumerable extension methods could be trimmed causing the application to fail at runtime.")>]
static member AsQueryable : seq<'Element> -> System.Linq.IQueryable<'Element>
[<System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Enumerating in-memory collections as IQueryable can require unreferenced code because expressions referencing IQueryable extension methods can get rebound to IEnumerable extension methods. The IEnumerable extension methods could be trimmed causing the application to fail at runtime.")>]
static member AsQueryable : seq<'Element> -> System.Linq.IQueryable<'Element>
[<System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Enumerating in-memory collections as IQueryable can require unreferenced code because expressions referencing IQueryable extension methods can get rebound to IEnumerable extension methods. The IEnumerable extension methods could be trimmed causing the application to fail at runtime.")>]
[<System.Diagnostics.CodeAnalysis.RequiresDynamicCode("Enumerating collections as IQueryable can require creating new generic types or methods, which requires creating code at runtime. This may not work when AOT compiling.")>]
static member AsQueryable : seq<'Element> -> System.Linq.IQueryable<'Element>
<Extension()>
Public Function AsQueryable(Of TElement) (source As IEnumerable(Of TElement)) As IQueryable(Of TElement)

Typparameter

TElement

Der Typ der Elemente von source.

Parameter

source
IEnumerable<TElement>

Eine zu konvertierende Sequenz.

Gibt zurück

IQueryable<TElement>

Ein IQueryable<T> Wert, der die Eingabesequenz darstellt.

Attribute

Ausnahmen

source ist null.

Beispiele

Im folgenden Codebeispiel wird veranschaulicht, wie sie zum AsQueryable<TElement>(IEnumerable<TElement>) Konvertieren eines IEnumerable<T> Elements in ein 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

Hinweise

Wenn der Typ der source Implementierungen erfolgt IQueryable<T>, wird AsQueryable<TElement>(IEnumerable<TElement>) sie direkt zurückgegeben. Andernfalls wird eine IQueryable<T> Abfrage zurückgegeben, die Abfragen ausführt, indem die entsprechenden Abfrageoperatormethoden Enumerable anstelle dieser in Queryableaufgerufen werden.

Gilt für: