Queryable.Skip<TSource>(IQueryable<TSource>, Int32) Metodo
Definizione
Importante
Alcune informazioni sono relative alla release non definitiva del prodotto, che potrebbe subire modifiche significative prima della release definitiva. Microsoft non riconosce alcuna garanzia, espressa o implicita, in merito alle informazioni qui fornite.
Ignora un numero specificato di elementi in una sequenza e quindi restituisce gli elementi rimanenti.
public:
generic <typename TSource>
[System::Runtime::CompilerServices::Extension]
static System::Linq::IQueryable<TSource> ^ Skip(System::Linq::IQueryable<TSource> ^ source, int count);
public static System.Linq.IQueryable<TSource> Skip<TSource>(this System.Linq.IQueryable<TSource> source, int count);
[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<TSource> Skip<TSource>(this System.Linq.IQueryable<TSource> source, int count);
static member Skip : System.Linq.IQueryable<'Source> * int -> System.Linq.IQueryable<'Source>
[<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 Skip : System.Linq.IQueryable<'Source> * int -> System.Linq.IQueryable<'Source>
<Extension()>
Public Function Skip(Of TSource) (source As IQueryable(Of TSource), count As Integer) As IQueryable(Of TSource)
Parametri di tipo
- TSource
Tipo degli elementi di source.
Parametri
- source
- IQueryable<TSource>
Oggetto IQueryable<T> da cui restituire elementi.
- count
- Int32
Numero di elementi da ignorare prima di restituire gli elementi rimanenti.
Restituisce
Oggetto IQueryable<T> che contiene elementi che si verificano dopo l'indice specificato nella sequenza di input.
- Attributi
Eccezioni
source è null.
Esempio
Nell'esempio di codice seguente viene illustrato come usare Skip<TSource>(IQueryable<TSource>, Int32) per ignorare un numero specificato di elementi in una matrice ordinata e restituire gli elementi rimanenti.
int[] grades = { 59, 82, 70, 56, 92, 98, 85 };
// Sort the grades in descending order and
// get all except the first three.
IEnumerable<int> lowerGrades =
grades.AsQueryable().OrderByDescending(g => g).Skip(3);
Console.WriteLine("All grades except the top three are:");
foreach (int grade in lowerGrades)
Console.WriteLine(grade);
/*
This code produces the following output:
All grades except the top three are:
82
70
59
56
*/
Dim grades() As Integer = {59, 82, 70, 56, 92, 98, 85}
' Sort the grades in descending order and
' get all except the first three.
Dim lowerGrades = grades.AsQueryable() _
.OrderByDescending(Function(g) g) _
.Skip(3)
Dim output As New System.Text.StringBuilder
output.AppendLine("All grades except the top three are:")
For Each grade As Integer In lowerGrades
output.AppendLine(grade)
Next
' Display the output.
MsgBox(output.ToString())
' This code produces the following output:
' All grades except the top three are:
' 82
' 70
' 59
' 56
Commenti
Il Skip<TSource>(IQueryable<TSource>, Int32) metodo genera un oggetto MethodCallExpression che rappresenta la chiamata Skip<TSource>(IQueryable<TSource>, Int32) stessa come metodo generico costruito. Passa quindi l'oggetto MethodCallExpression al CreateQuery(Expression) metodo dell'oggetto IQueryProvider rappresentato dalla Provider proprietà del source parametro .
Il comportamento della query che si verifica come risultato dell'esecuzione di un albero delle espressioni che rappresenta la chiamata Skip<TSource>(IQueryable<TSource>, Int32) dipende dall'implementazione del tipo del source parametro. Il comportamento previsto è che ignora i primi count elementi in source e restituisce gli elementi rimanenti.