XPathMessageQueryCollection 類別

定義

包含 XPathMessageQuery 物件的集合。

public ref class XPathMessageQueryCollection : System::ServiceModel::Dispatcher::MessageQueryCollection
public class XPathMessageQueryCollection : System.ServiceModel.Dispatcher.MessageQueryCollection
type XPathMessageQueryCollection = class
    inherit MessageQueryCollection
Public Class XPathMessageQueryCollection
Inherits MessageQueryCollection
繼承
XPathMessageQueryCollection

範例

下列範例會建立訊息和 XPath 訊息查詢。 查詢會由包含在 XPathMessageQuery 物件內的 XPathMessageQueryCollection 物件評估。 每一個查詢的結果都會使用 ResultType 類別的 XPathResult 屬性測試。

using System;
using System.IO;
using System.Xml;
using System.ServiceModel.Dispatcher;
using System.ServiceModel;
using System.ServiceModel.Channels;
using System.Xml.XPath;

namespace MessageQueryExamples
{

    class Program
    {
        static void Main(string[] args)
        {
            // The XPathMessageQueryCollection inherits from MessageQueryCollection.
            XPathMessageQueryCollection queryCollection = MessageHelper.SetupQueryCollection();

            // Create a message and a copy of the message. You must create a buffered copy to access the message body.
            Message mess = MessageHelper.CreateMessage();
            MessageBuffer mb = mess.CreateBufferedCopy(int.MaxValue);

            // Evaluate every query in the collection.
            foreach (XPathMessageQuery q in queryCollection)
            {
                // Evaluate the query. Note the result type is an XPathResult.
                XPathResult qPathResult = q.Evaluate<XPathResult>(mb);

                // Use the XPathResult to determine the result type.
                Console.WriteLine("Result type: {0}", qPathResult.ResultType);

                // The following code prints the result according to the result type.

                if (qPathResult.ResultType == XPathResultType.String)
                    Console.WriteLine("{0} = {1}", q.Expression, qPathResult.GetResultAsString());

                if (qPathResult.ResultType == XPathResultType.NodeSet)
                {
                    // Iterate through the node set.
                    XPathNodeIterator ns = qPathResult.GetResultAsNodeset();
                    foreach (XPathNavigator n in ns)
                        Console.WriteLine("\t{0} = {1}", q.Expression, n.Value);
                }
                if (qPathResult.ResultType == XPathResultType.Number)
                    Console.WriteLine("\t{0} = {1}", q.Expression, qPathResult.GetResultAsNumber());

                if (qPathResult.ResultType == XPathResultType.Boolean)
                    Console.WriteLine("\t{0} ={1}", q.Expression, qPathResult.GetResultAsBoolean());

                if (qPathResult.ResultType == XPathResultType.Error)
                    Console.WriteLine("\tError!");
            }

            Console.WriteLine();

            // The alternate code below demonstrates similar funcionality using a MessageQueryTable.
            // The difference is the KeyValuePair that requires a key to index each value.
            // The code uses the expression as the key, and an arbitrary value for the value.

            //MessageQueryTable<string> mq = MessageHelper.SetupTable();
            //foreach (KeyValuePair<MessageQuery, string> kv in mq)
            //{
            //    XPathMessageQuery xp = (XPathMessageQuery)kv.Key;
            //    Console.WriteLine("Value = {0}", kv.Value);
            //    Console.WriteLine("{0} = {1}", xp.Expression, xp.Evaluate<string>(mb));
            //}

            Console.ReadLine();
        }
    }

    public class MessageHelper
    {
        static string messageBody =
              "<PurchaseOrder date='today'>" +
                  "<Number>ABC-2009-XYZ</Number>" +
                  "<Department>OnlineSales</Department>" +
                  "<Items>" +
                      "<Item product='nail' quantity='1'>item1</Item>" +
                      "<Item product='screw' quantity='2'>item2</Item>" +
                      "<Item product='brad' quantity='3'>" +
                          "<SpecialOffer/>" +
                          "Special item4" +
                      "</Item>" +
                      "<Item product='SpecialNails' quantity='9'>item5</Item>" +
                      "<Item product='SpecialBrads' quantity='11'>" +
                          "<SpecialOffer/>" +
                          "Special item6" +
                      "</Item>" +
                      "<Item product='hammer' quantity='1'>item7</Item>" +
                      "<Item product='wrench' quantity='2'>item8</Item>" +
                  "</Items>" +
                "<Comments>" +
                "Rush order" +
                "</Comments>" +
              "</PurchaseOrder>";

        public static string xpath = "/s12:Envelope/s12:Body/PurchaseOrder/Items/Item[@quantity = 1]";
        public static string xpath2 = "/s12:Envelope/s12:Body/PurchaseOrder/Items/Item[@product = 'nail']";
        public static string xpath3 = "/s12:Envelope/s12:Body/PurchaseOrder/Comments";
        public static string xpath4 = "count(/s12:Envelope/s12:Body/PurchaseOrder/Items/Item)";
        public static string xpath5 = "substring(string(/s12:Envelope/s12:Body/PurchaseOrder/Number),5,4)";
        public static string xpath6 = "/s12:Envelope/s12:Body/PurchaseOrder/Department='OnlineSales'";
        public static string xpath7 = "//PurchaseOrder/@date";
        public static string xpath8 = "//SpecialOffer/ancestor::Item[@product = 'brad']";

        // Invoke the correlation data function.
        public static string xpath9 = "sm:correlation-data('CorrelationData1')";
        public static string xpath10 = "sm:correlation-data('CorrelationData2')";

        public static string xpath11 = "/s12:Envelope/s12:Body/PurchaseOrder/Items/Item[@quantity = 2]";

        public static Message CreateMessage()
        {
            StringReader stringReader = new StringReader(messageBody);
            XmlTextReader xmlReader = new XmlTextReader(stringReader);
            Message message = Message.CreateMessage(MessageVersion.Soap12WSAddressing10, "http://purchaseorder", xmlReader);

            // Add two correlation properties using lambda expressions. The property names are
            // CorrelationData1 and CorrelationData2. The first goes to "value1" and the
            // second to "value2". You can use your own property names and values.
            CorrelationDataMessageProperty data = new CorrelationDataMessageProperty();

            data.Add("CorrelationData1", () => "value1");
            data.Add("CorrelationData2", () => "value2");
            message.Properties[CorrelationDataMessageProperty.Name] = data;

            return message;
        }

        public static XPathMessageQueryCollection SetupQueryCollection()
        {
            // Create the query collection and add the XPath queries to it. To create
            // the query, you must also use a new XPathMessageContext.

            XPathMessageQueryCollection queryCollection = new XPathMessageQueryCollection();

            XPathMessageContext context = new XPathMessageContext();
            queryCollection.Add(new XPathMessageQuery(xpath, context));
            queryCollection.Add(new XPathMessageQuery(xpath2, context));
            queryCollection.Add(new XPathMessageQuery(xpath3, context));
            queryCollection.Add(new XPathMessageQuery(xpath4, context));
            queryCollection.Add(new XPathMessageQuery(xpath5, context));
            queryCollection.Add(new XPathMessageQuery(xpath6, context));
            queryCollection.Add(new XPathMessageQuery(xpath7, context));
            queryCollection.Add(new XPathMessageQuery(xpath8, context));
            queryCollection.Add(new XPathMessageQuery(xpath9, context));
            queryCollection.Add(new XPathMessageQuery(xpath10, context));
            queryCollection.Add(new XPathMessageQuery(xpath11, context));

            return queryCollection;
        }

        public static MessageQueryTable<string> SetupTable()
        {
            // This is optional code to demonstrate using a MessageQueryTable.
            // Compare this to the MessageQueryCollection.
            MessageQueryTable<string> table = new MessageQueryTable<string>();
            XPathMessageContext context = new XPathMessageContext();

            // The code adds a KeyValuePair to the table. Each pair requires
            // a query used as the Key, and a value that is paired to the key.
            table.Add(new XPathMessageQuery(xpath, context), "value10");
            table.Add(new XPathMessageQuery(xpath2, context), "value20");
            table.Add(new XPathMessageQuery(xpath3, context), "value30");
            table.Add(new XPathMessageQuery(xpath4, context), "value40");
            table.Add(new XPathMessageQuery(xpath5, context), "value50");
            table.Add(new XPathMessageQuery(xpath6, context), "value60");
            table.Add(new XPathMessageQuery(xpath7, context), "value70");
            table.Add(new XPathMessageQuery(xpath8, context), "value80");
            table.Add(new XPathMessageQuery(xpath9, context), "value90");
            table.Add(new XPathMessageQuery(xpath10, context), "value100");
            table.Add(new XPathMessageQuery(xpath11, context), "value110");
            return table;
        }
    }
}
Imports System.IO
Imports System.Xml
Imports System.ServiceModel.Dispatcher
Imports System.ServiceModel
Imports System.ServiceModel.Channels
Imports System.Xml.XPath

Namespace MessageQueryExamples


    Public Class Program

        Public Shared Sub Main(ByVal args As String())

            ' The XPathMessageQueryCollection inherits from MessageQueryCollection.
            Dim queryCollection As XPathMessageQueryCollection = MessageHelper.SetupQueryCollection()


            ' Create a message and a copy of the message. You must create a buffered copy to access the message body.
            Dim mess As Message = MessageHelper.CreateMessage()
            Dim mb As MessageBuffer = mess.CreateBufferedCopy(Integer.MaxValue)


            ' Evaluate every query in the collection. 
            Dim q As XPathMessageQuery
            For Each q In queryCollection

                ' Evaluate the query. Note the result type is an XPathResult.
                Dim qPathResult As XPathResult = q.Evaluate(Of XPathResult)(mb)

                ' Use the XPathResult to determine the result type.
                Console.WriteLine("Result type: {0}", qPathResult.ResultType)

                ' The following code prints the result according to the result type.

                If qPathResult.ResultType = XPathResultType.String Then
                    Console.WriteLine("{0} = {1}", q.Expression, qPathResult.GetResultAsString())
                End If
                If (qPathResult.ResultType = XPathResultType.NodeSet) Then

                    ' Iterate through the node set.
                    Dim ns As XPathNodeIterator = qPathResult.GetResultAsNodeset()
                    Dim n As XPathNavigator
                    For Each n In ns
                        Console.WriteLine("     {0} = {1}", q.Expression, n.Value)
                    Next
                End If
                If qPathResult.ResultType = XPathResultType.Number Then
                    Console.WriteLine("    {0} = {1}", q.Expression, qPathResult.GetResultAsNumber())
                End If
                If qPathResult.ResultType = XPathResultType.Boolean Then
                    Console.WriteLine("    {0} ={1}", q.Expression, qPathResult.GetResultAsBoolean())
                End If

                If qPathResult.ResultType = XPathResultType.Error Then
                    Console.WriteLine("    Error!")
                End If

            Next

            Console.WriteLine()

            ' The alternate code below demonstrates similar funcionality using a MessageQueryTable.
            ' The difference is the KeyValuePair that requires a key to index each value.
            ' The code uses the expression as the key, and an arbitrary value for the value.           

            'Dim mq As MessageQueryTable(Of String) = MessageHelper.SetupTable()
            'Dim kv As KeyValuePair(Of MessageQuery, String)
            'For Each kv In mq
            '    '
            '    Dim xp As XPathMessageQuery = CType(kv.Key, XPathMessageQuery)
            '    Console.WriteLine("Value = {0}", kv.Value)
            '    Console.WriteLine("{0} = {1}", xp.Expression, xp.Evaluate(Of String)(mb))
            'Next

            Console.ReadLine()
        End Sub
        Private Shared Sub Evaluate(ByVal p1 As Object)
            Throw New NotImplementedException
        End Sub
    End Class

    Public Class MessageHelper

        Shared messageBody As String = _
              "<PurchaseOrder date='today'>" + _
                  "<Number>ABC-2009-XYZ</Number>" + _
                  "<Department>OnlineSales</Department>" + _
                  "<Items>" + _
                      "<Item product='nail' quantity='1'>item1</Item>" + _
                      "<Item product='screw' quantity='2'>item2</Item>" + _
                      "<Item product='brad' quantity='3'>" + _
                          "<SpecialOffer/>" + _
                          "Special item4" + _
                      "</Item>" + _
                      "<Item product='SpecialNails' quantity='9'>item5</Item>" + _
                      "<Item product='SpecialBrads' quantity='11'>" + _
                          "<SpecialOffer/>" + _
                          "Special item6" + _
                      "</Item>" + _
                      "<Item product='hammer' quantity='1'>item7</Item>" + _
                      "<Item product='wrench' quantity='2'>item8</Item>" + _
                  "</Items>" + _
                "<Comments>" + _
                "Rush order" + _
                "</Comments>" + _
              "</PurchaseOrder>"

        Public Shared xpath As String = "/s12:Envelope/s12:Body/PurchaseOrder/Items/Item[@quantity = 1]"
        Public Shared xpath2 As String = "/s12:Envelope/s12:Body/PurchaseOrder/Items/Item[@product = 'nail']"
        Public Shared xpath3 As String = "/s12:Envelope/s12:Body/PurchaseOrder/Comments"
        Public Shared xpath4 As String = "count(/s12:Envelope/s12:Body/PurchaseOrder/Items/Item)"
        Public Shared xpath5 As String = "substring(string(/s12:Envelope/s12:Body/PurchaseOrder/Number),5,4)"
        Public Shared xpath6 As String = "/s12:Envelope/s12:Body/PurchaseOrder/Department='OnlineSales'"
        Public Shared xpath7 As String = "//PurchaseOrder/@date"
        Public Shared xpath8 As String = "//SpecialOffer/ancestor::Item[@product = 'brad']"

        ' Invoke the correlation data function.


        Public Shared xpath9 As String = "sm:correlation-data('CorrelationData1')"
        Public Shared xpath10 As String = "sm:correlation-data('CorrelationData2')"

        Public Shared xpath11 As String = "/s12:Envelope/s12:Body/PurchaseOrder/Items/Item[@quantity = 2]"


        Public Shared Function CreateMessage() As Message

            Dim stringReader As New StringReader(messageBody)
            Dim xmlReader As New XmlTextReader(stringReader)
            Dim message As Message = message.CreateMessage( _
                MessageVersion.Soap12WSAddressing10, "http://purchaseorder", xmlReader)

            ' Add two correlation properties using lambda expressions. The property names are
            ' CorrelationData1 and CorrelationData2. The first goes to "value1" and the
            ' second to "value2". You can use your own property names and values.
            Dim data As New CorrelationDataMessageProperty()

            data.Add("CorrelationData1", Function() "value1")
            data.Add("CorrelationData2", Function() "value2")
            message.Properties(CorrelationDataMessageProperty.Name) = data


            Return message
        End Function


        Public Shared Function SetupQueryCollection() As XPathMessageQueryCollection

            ' Create the query collection and add the XPath queries to it. To create
            ' the query, you must also use a new XPathMessageContext.

            Dim queryCollection As New XPathMessageQueryCollection()

            Dim context As XPathMessageContext = New XPathMessageContext()
            queryCollection.Add(New XPathMessageQuery(xpath, context))
            queryCollection.Add(New XPathMessageQuery(xpath2, context))
            queryCollection.Add(New XPathMessageQuery(xpath3, context))
            queryCollection.Add(New XPathMessageQuery(xpath4, context))
            queryCollection.Add(New XPathMessageQuery(xpath5, context))
            queryCollection.Add(New XPathMessageQuery(xpath6, context))
            queryCollection.Add(New XPathMessageQuery(xpath7, context))
            queryCollection.Add(New XPathMessageQuery(xpath8, context))
            queryCollection.Add(New XPathMessageQuery(xpath9, context))
            queryCollection.Add(New XPathMessageQuery(xpath10, context))
            queryCollection.Add(New XPathMessageQuery(xpath11, context))

            Return queryCollection
        End Function

        Public Shared Function SetupTable() As MessageQueryTable(Of String)

            ' This is optional code to demonstrate using a MessageQueryTable.
            ' Compare this to the MessageQueryCollection.
            Dim table As MessageQueryTable(Of String) = New MessageQueryTable(Of String)()
            Dim context As XPathMessageContext = New XPathMessageContext()


            ' The code adds a KeyValuePair to the table. Each pair requires
            ' a query used as the Key, and a value that is paired to the key.
            table.Add(New XPathMessageQuery(xpath, context), "value10")
            table.Add(New XPathMessageQuery(xpath2, context), "value20")
            table.Add(New XPathMessageQuery(xpath3, context), "value30")
            table.Add(New XPathMessageQuery(xpath4, context), "value40")
            table.Add(New XPathMessageQuery(xpath5, context), "value50")
            table.Add(New XPathMessageQuery(xpath6, context), "value60")
            table.Add(New XPathMessageQuery(xpath7, context), "value70")
            table.Add(New XPathMessageQuery(xpath8, context), "value80")
            table.Add(New XPathMessageQuery(xpath9, context), "value90")
            table.Add(New XPathMessageQuery(xpath10, context), "value100")
            table.Add(New XPathMessageQuery(xpath11, context), "value110")
            Return table
        End Function
    End Class
End Namespace

備註

如需訊息查詢的詳細資訊,請參閱 MessageQueryMessageQueryCollection 類別。

建構函式

XPathMessageQueryCollection()

初始化 XPathMessageQueryCollection 類別的新執行個體。

屬性

Count

取得 Collection<T> 中實際包含的項目數目。

(繼承來源 Collection<T>)
Item[Int32]

在指定的索引位置上取得或設定項目。

(繼承來源 Collection<T>)
Items

取得 IList<T> 周圍的 Collection<T> 包裝函式。

(繼承來源 Collection<T>)

方法

Add(T)

將物件加入至 Collection<T> 的末端。

(繼承來源 Collection<T>)
Clear()

移除 Collection<T> 中的所有項目。

(繼承來源 Collection<T>)
ClearItems()

移除 Collection<T> 中的所有項目。

(繼承來源 Collection<T>)
Contains(T)

判斷某項目是否在 Collection<T> 中。

(繼承來源 Collection<T>)
CopyTo(T[], Int32)

從目標陣列的指定索引開始,將整個 Collection<T> 複製到相容的一維 Array

(繼承來源 Collection<T>)
Equals(Object)

判斷指定的物件是否等於目前的物件。

(繼承來源 Object)
Evaluate<TResult>(Message)

針對訊息執行查詢。 本文無法進行查詢。

Evaluate<TResult>(MessageBuffer)

針對訊息執行 XPath 查詢。

GetEnumerator()

傳回在 Collection<T> 中逐一查看的列舉值。

(繼承來源 Collection<T>)
GetHashCode()

做為預設雜湊函式。

(繼承來源 Object)
GetType()

取得目前執行個體的 Type

(繼承來源 Object)
IndexOf(T)

搜尋指定的物件,並傳回整個 Collection<T> 中第一個出現之以零為起始的索引。

(繼承來源 Collection<T>)
Insert(Int32, T)

將項目插入至 Collection<T> 中指定的索引位置。

(繼承來源 Collection<T>)
InsertItem(Int32, MessageQuery)

將 XPath 查詢物件插入集合中指定的索引位置。

InsertItem(Int32, T)

將項目插入至 Collection<T> 中指定的索引位置。

(繼承來源 Collection<T>)
MemberwiseClone()

建立目前 Object 的淺層複製。

(繼承來源 Object)
Remove(T)

Collection<T> 移除特定物件之第一個符合的元素。

(繼承來源 Collection<T>)
RemoveAt(Int32)

移除 Collection<T> 之指定索引處的項目。

(繼承來源 Collection<T>)
RemoveItem(Int32)

從集合中的指定索引處移除項目。

SetItem(Int32, MessageQuery)

取代指定之索引處的項目。

SetItem(Int32, T)

取代指定之索引處的項目。

(繼承來源 Collection<T>)
ToString()

傳回代表目前物件的字串。

(繼承來源 Object)

明確介面實作

ICollection.CopyTo(Array, Int32)

從特定的 ICollection 索引開始,將 Array 的項目複製到 Array

(繼承來源 Collection<T>)
ICollection.IsSynchronized

取得值,這個值表示對 ICollection 的存取是否同步 (安全執行緒)。

(繼承來源 Collection<T>)
ICollection.SyncRoot

取得可用以同步存取 ICollection 的物件。

(繼承來源 Collection<T>)
ICollection<T>.IsReadOnly

取得值,指出 ICollection<T> 是否唯讀。

(繼承來源 Collection<T>)
IEnumerable.GetEnumerator()

傳回逐一查看集合的列舉值。

(繼承來源 Collection<T>)
IList.Add(Object)

將項目加入至 IList

(繼承來源 Collection<T>)
IList.Contains(Object)

判斷 IList 是否包含特定值。

(繼承來源 Collection<T>)
IList.IndexOf(Object)

判斷 IList 中指定項目的索引。

(繼承來源 Collection<T>)
IList.Insert(Int32, Object)

將項目插入 IList 中指定的索引處。

(繼承來源 Collection<T>)
IList.IsFixedSize

取得值,指出 IList 是否有固定的大小。

(繼承來源 Collection<T>)
IList.IsReadOnly

取得值,指出 IList 是否唯讀。

(繼承來源 Collection<T>)
IList.Item[Int32]

在指定的索引位置上取得或設定項目。

(繼承來源 Collection<T>)
IList.Remove(Object)

IList 移除特定物件之第一個符合的元素。

(繼承來源 Collection<T>)

擴充方法

CopyToDataTable<T>(IEnumerable<T>)

根據輸入 DataTable 物件 (其中泛型參數 TDataRow) 傳回包含 IEnumerable<T> 物件複本的 DataRow

CopyToDataTable<T>(IEnumerable<T>, DataTable, LoadOption)

根據輸入 DataRow 物件 (其中泛型參數 TDataTable),將 IEnumerable<T> 物件複製到指定的 DataRow

CopyToDataTable<T>(IEnumerable<T>, DataTable, LoadOption, FillErrorEventHandler)

根據輸入 DataRow 物件 (其中泛型參數 TDataTable),將 IEnumerable<T> 物件複製到指定的 DataRow

Aggregate<TSource>(IEnumerable<TSource>, Func<TSource,TSource,TSource>)

將累加函式套用到序列上。

Aggregate<TSource,TAccumulate>(IEnumerable<TSource>, TAccumulate, Func<TAccumulate,TSource,TAccumulate>)

將累加函式套用到序列上。 使用指定的初始值做為初始累加值。

Aggregate<TSource,TAccumulate,TResult>(IEnumerable<TSource>, TAccumulate, Func<TAccumulate,TSource,TAccumulate>, Func<TAccumulate,TResult>)

將累加函式套用到序列上。 使用指定的值做為初始累加值,並使用指定的函式來選取結果值。

All<TSource>(IEnumerable<TSource>, Func<TSource,Boolean>)

判斷序列的所有項目是否全都符合條件。

Any<TSource>(IEnumerable<TSource>)

判斷序列是否包含任何項目。

Any<TSource>(IEnumerable<TSource>, Func<TSource,Boolean>)

判斷序列的任何項目是否符合條件。

Append<TSource>(IEnumerable<TSource>, TSource)

將值附加在序列結尾。

AsEnumerable<TSource>(IEnumerable<TSource>)

傳回 IEnumerable<T> 類型的輸入。

Average<TSource>(IEnumerable<TSource>, Func<TSource,Decimal>)

計算在輸入序列中各項目上叫用轉換函式後所取得之 Decimal 值序列的平均值。

Average<TSource>(IEnumerable<TSource>, Func<TSource,Double>)

計算在輸入序列中各項目上叫用轉換函式後所取得之 Double 值序列的平均值。

Average<TSource>(IEnumerable<TSource>, Func<TSource,Int32>)

計算在輸入序列中各項目上叫用轉換函式後所取得之 Int32 值序列的平均值。

Average<TSource>(IEnumerable<TSource>, Func<TSource,Int64>)

計算在輸入序列中各項目上叫用轉換函式後所取得之 Int64 值序列的平均值。

Average<TSource>(IEnumerable<TSource>, Func<TSource,Nullable<Decimal>>)

計算在輸入序列中各項目上叫用轉換函式後所取得可為 Null 之 Decimal 值的平均值。

Average<TSource>(IEnumerable<TSource>, Func<TSource,Nullable<Double>>)

計算在輸入序列中各項目上叫用轉換函式後所取得可為 Null 之 Double 值的平均值。

Average<TSource>(IEnumerable<TSource>, Func<TSource,Nullable<Int32>>)

計算在輸入序列中各項目上叫用轉換函式後所取得可為 Null 之 Int32 值的平均值。

Average<TSource>(IEnumerable<TSource>, Func<TSource,Nullable<Int64>>)

計算在輸入序列中各項目上叫用轉換函式後所取得可為 Null 之 Int64 值的平均值。

Average<TSource>(IEnumerable<TSource>, Func<TSource,Nullable<Single>>)

計算在輸入序列中各項目上叫用轉換函式後所取得可為 Null 之 Single 值的平均值。

Average<TSource>(IEnumerable<TSource>, Func<TSource,Single>)

計算在輸入序列中各項目上叫用轉換函式後所取得之 Single 值序列的平均值。

Cast<TResult>(IEnumerable)

IEnumerable 的項目轉換成指定的型別。

Concat<TSource>(IEnumerable<TSource>, IEnumerable<TSource>)

串連兩個序列。

Contains<TSource>(IEnumerable<TSource>, TSource)

使用預設的相等比較子 (Comparer) 來判斷序列是否包含指定的項目。

Contains<TSource>(IEnumerable<TSource>, TSource, IEqualityComparer<TSource>)

使用指定的 IEqualityComparer<T> 來判斷序列是否包含指定的項目。

Count<TSource>(IEnumerable<TSource>)

傳回序列中的項目數。

Count<TSource>(IEnumerable<TSource>, Func<TSource,Boolean>)

傳回數字,代表指定之序列中符合條件的項目數目。

DefaultIfEmpty<TSource>(IEnumerable<TSource>)

傳回指定之序列的項目;如果序列是空的,則傳回單一集合中型別參數的預設值。

DefaultIfEmpty<TSource>(IEnumerable<TSource>, TSource)

傳回指定之序列的項目;如果序列是空的,則傳回單一集合中型別參數的預設值。

Distinct<TSource>(IEnumerable<TSource>)

使用預設的相等比較子來比較值,以便從序列傳回獨特的項目。

Distinct<TSource>(IEnumerable<TSource>, IEqualityComparer<TSource>)

使用指定的 IEqualityComparer<T> 來比較值,以便從序列傳回獨特的項目。

ElementAt<TSource>(IEnumerable<TSource>, Int32)

傳回位於序列中指定索引處的項目。

ElementAtOrDefault<TSource>(IEnumerable<TSource>, Int32)

傳回位於序列中指定索引處的元素;如果索引超出範圍,則傳回預設值。

Except<TSource>(IEnumerable<TSource>, IEnumerable<TSource>)

使用預設相等比較子來比較值,以便產生兩個序列的差異。

Except<TSource>(IEnumerable<TSource>, IEnumerable<TSource>, IEqualityComparer<TSource>)

使用指定的 IEqualityComparer<T> 來比較值,以便產生兩個序列的差異。

First<TSource>(IEnumerable<TSource>)

傳回序列的第一個項目。

First<TSource>(IEnumerable<TSource>, Func<TSource,Boolean>)

傳回序列中符合指定條件的第一個元素。

FirstOrDefault<TSource>(IEnumerable<TSource>)

傳回序列的第一個元素;如果序列中沒有包含任何元素,則傳回預設值。

FirstOrDefault<TSource>(IEnumerable<TSource>, Func<TSource,Boolean>)

傳回序列中符合條件的第一個元素;如果找不到這類元素,則傳回預設值。

GroupBy<TSource,TKey>(IEnumerable<TSource>, Func<TSource,TKey>)

依據指定的索引鍵選擇器函式來群組序列的項目。

GroupBy<TSource,TKey>(IEnumerable<TSource>, Func<TSource,TKey>, IEqualityComparer<TKey>)

依據指定的索引鍵選取器函式來群組序列的項目,並使用指定的比較子來比較索引鍵。

GroupBy<TSource,TKey,TElement>(IEnumerable<TSource>, Func<TSource,TKey>, Func<TSource,TElement>)

依據指定的索引鍵選取器函式來群組序列的項目,並使用指定的函式來投影每個群組的項目。

GroupBy<TSource,TKey,TElement>(IEnumerable<TSource>, Func<TSource,TKey>, Func<TSource,TElement>, IEqualityComparer<TKey>)

依據索引鍵選取器函式來群組序列中的項目。 索引鍵是使用比較子來進行比較,而每個群組的項目都是利用指定的函式進行投影。

GroupBy<TSource,TKey,TResult>(IEnumerable<TSource>, Func<TSource,TKey>, Func<TKey,IEnumerable<TSource>,TResult>)

依據指定的索引鍵選取器函式來群組序列的項目,並從每個群組及其索引鍵建立結果值。

GroupBy<TSource,TKey,TResult>(IEnumerable<TSource>, Func<TSource,TKey>, Func<TKey,IEnumerable<TSource>,TResult>, IEqualityComparer<TKey>)

依據指定的索引鍵選取器函式來群組序列的項目,並從每個群組及其索引鍵建立結果值。 索引鍵是使用指定的比較子來進行比較。

GroupBy<TSource,TKey,TElement,TResult>(IEnumerable<TSource>, Func<TSource,TKey>, Func<TSource,TElement>, Func<TKey,IEnumerable<TElement>,TResult>)

依據指定的索引鍵選取器函式來群組序列的項目,並從每個群組及其索引鍵建立結果值。 每個群組的項目都是利用指定的函式進行投影。

GroupBy<TSource,TKey,TElement,TResult>(IEnumerable<TSource>, Func<TSource, TKey>, Func<TSource,TElement>, Func<TKey,IEnumerable<TElement>, TResult>, IEqualityComparer<TKey>)

依據指定的索引鍵選取器函式來群組序列的項目,並從每個群組及其索引鍵建立結果值。 索引鍵值是使用指定的比較子來進行比較,而每個群組的項目則都是利用指定的函式進行投影。

GroupJoin<TOuter,TInner,TKey,TResult>(IEnumerable<TOuter>, IEnumerable<TInner>, Func<TOuter,TKey>, Func<TInner,TKey>, Func<TOuter,IEnumerable<TInner>, TResult>)

根據索引鍵相等與否,將兩個序列的項目相互關聯,並群組產生的結果。 預設的相等比較子是用於比較索引鍵。

GroupJoin<TOuter,TInner,TKey,TResult>(IEnumerable<TOuter>, IEnumerable<TInner>, Func<TOuter,TKey>, Func<TInner,TKey>, Func<TOuter,IEnumerable<TInner>, TResult>, IEqualityComparer<TKey>)

根據索引鍵相等與否,將兩個序列的項目相互關聯,並群組產生的結果。 指定的 IEqualityComparer<T> 是用於比較索引鍵。

Intersect<TSource>(IEnumerable<TSource>, IEnumerable<TSource>)

使用預設相等比較子來比較值,以便產生兩個序列的交集。

Intersect<TSource>(IEnumerable<TSource>, IEnumerable<TSource>, IEqualityComparer<TSource>)

使用指定的 IEqualityComparer<T> 來比較值,以便產生兩個序列的交集。

Join<TOuter,TInner,TKey,TResult>(IEnumerable<TOuter>, IEnumerable<TInner>, Func<TOuter,TKey>, Func<TInner,TKey>, Func<TOuter,TInner,TResult>)

根據相符索引鍵,將兩個序列的項目相互關聯。 預設的相等比較子是用於比較索引鍵。

Join<TOuter,TInner,TKey,TResult>(IEnumerable<TOuter>, IEnumerable<TInner>, Func<TOuter,TKey>, Func<TInner,TKey>, Func<TOuter,TInner,TResult>, IEqualityComparer<TKey>)

根據相符索引鍵,將兩個序列的項目相互關聯。 指定的 IEqualityComparer<T> 是用於比較索引鍵。

Last<TSource>(IEnumerable<TSource>)

傳回序列的最後一個項目。

Last<TSource>(IEnumerable<TSource>, Func<TSource,Boolean>)

傳回序列中符合指定之條件的最後一個元素。

LastOrDefault<TSource>(IEnumerable<TSource>)

傳回序列的最後一個元素;如果序列中沒有包含任何元素,則傳回預設值。

LastOrDefault<TSource>(IEnumerable<TSource>, Func<TSource,Boolean>)

傳回序列中符合條件的最後一個元素;如果找不到這類元素,則傳回預設值。

LongCount<TSource>(IEnumerable<TSource>)

傳回代表序列中項目總數的 Int64

LongCount<TSource>(IEnumerable<TSource>, Func<TSource,Boolean>)

傳回 Int64,其代表序列中符合條件的項目數目。

Max<TSource>(IEnumerable<TSource>)

傳回泛型序列中的最大值。

Max<TSource>(IEnumerable<TSource>, Func<TSource,Decimal>)

在序列的每個項目上叫用轉換函式,並傳回最大的 Decimal 值。

Max<TSource>(IEnumerable<TSource>, Func<TSource,Double>)

在序列的每個項目上叫用轉換函式,並傳回最大的 Double 值。

Max<TSource>(IEnumerable<TSource>, Func<TSource,Int32>)

在序列的每個項目上叫用轉換函式,並傳回最大的 Int32 值。

Max<TSource>(IEnumerable<TSource>, Func<TSource,Int64>)

在序列的每個項目上叫用轉換函式,並傳回最大的 Int64 值。

Max<TSource>(IEnumerable<TSource>, Func<TSource,Nullable<Decimal>>)

在序列的每個項目上叫用轉換函式,並傳回最大的可為 Null 之 Decimal 值。

Max<TSource>(IEnumerable<TSource>, Func<TSource,Nullable<Double>>)

在序列的每個項目上叫用轉換函式,並傳回最大的可為 Null 之 Double 值。

Max<TSource>(IEnumerable<TSource>, Func<TSource,Nullable<Int32>>)

在序列的每個項目上叫用轉換函式,並傳回最大的可為 Null 之 Int32 值。

Max<TSource>(IEnumerable<TSource>, Func<TSource,Nullable<Int64>>)

在序列的每個項目上叫用轉換函式,並傳回最大的可為 Null 之 Int64 值。

Max<TSource>(IEnumerable<TSource>, Func<TSource,Nullable<Single>>)

在序列的每個項目上叫用轉換函式,並傳回最大的可為 Null 之 Single 值。

Max<TSource>(IEnumerable<TSource>, Func<TSource,Single>)

在序列的每個項目上叫用轉換函式,並傳回最大的 Single 值。

Max<TSource,TResult>(IEnumerable<TSource>, Func<TSource,TResult>)

在泛型序列的每個項目上叫用轉換函式,並傳回最大的結果值。

Min<TSource>(IEnumerable<TSource>)

傳回泛型序列中的最小值。

Min<TSource>(IEnumerable<TSource>, Func<TSource,Decimal>)

在序列的每個項目上叫用轉換函式,並傳回最小的 Decimal 值。

Min<TSource>(IEnumerable<TSource>, Func<TSource,Double>)

在序列的每個項目上叫用轉換函式,並傳回最小的 Double 值。

Min<TSource>(IEnumerable<TSource>, Func<TSource,Int32>)

在序列的每個項目上叫用轉換函式,並傳回最小的 Int32 值。

Min<TSource>(IEnumerable<TSource>, Func<TSource,Int64>)

在序列的每個項目上叫用轉換函式,並傳回最小的 Int64 值。

Min<TSource>(IEnumerable<TSource>, Func<TSource,Nullable<Decimal>>)

在序列的每個項目上叫用轉換函式,並傳回最小的可為 Null 之 Decimal 值。

Min<TSource>(IEnumerable<TSource>, Func<TSource,Nullable<Double>>)

在序列的每個項目上叫用轉換函式,並傳回最小的可為 Null 之 Double 值。

Min<TSource>(IEnumerable<TSource>, Func<TSource,Nullable<Int32>>)

在序列的每個項目上叫用轉換函式,並傳回最小的可為 Null 之 Int32 值。

Min<TSource>(IEnumerable<TSource>, Func<TSource,Nullable<Int64>>)

在序列的每個項目上叫用轉換函式,並傳回最小的可為 Null 之 Int64 值。

Min<TSource>(IEnumerable<TSource>, Func<TSource,Nullable<Single>>)

在序列的每個項目上叫用轉換函式,並傳回最小的可為 Null 之 Single 值。

Min<TSource>(IEnumerable<TSource>, Func<TSource,Single>)

在序列的每個項目上叫用轉換函式,並傳回最小的 Single 值。

Min<TSource,TResult>(IEnumerable<TSource>, Func<TSource,TResult>)

在泛型序列的每個項目上叫用轉換函式,並傳回最小的結果值。

OfType<TResult>(IEnumerable)

根據指定的型別來篩選 IEnumerable 的項目。

OrderBy<TSource,TKey>(IEnumerable<TSource>, Func<TSource,TKey>)

依據索引鍵,按遞增順序排序序列中的項目。

OrderBy<TSource,TKey>(IEnumerable<TSource>, Func<TSource,TKey>, IComparer<TKey>)

使用指定的比較子,依遞增順序排序序列中的項目。

OrderByDescending<TSource,TKey>(IEnumerable<TSource>, Func<TSource,TKey>)

依據索引鍵,按遞減順序排序序列中的項目。

OrderByDescending<TSource,TKey>(IEnumerable<TSource>, Func<TSource,TKey>, IComparer<TKey>)

使用指定的比較子,依遞減順序排序序列中的項目。

Prepend<TSource>(IEnumerable<TSource>, TSource)

將值新增至序列的開頭。

Reverse<TSource>(IEnumerable<TSource>)

反轉序列中項目的排序方向。

Select<TSource,TResult>(IEnumerable<TSource>, Func<TSource,TResult>)

將序列的每個元素規劃成一個新的表單。

Select<TSource,TResult>(IEnumerable<TSource>, Func<TSource,Int32,TResult>)

透過加入項目的索引,將序列的每個項目投影成新的表單。

SelectMany<TSource,TResult>(IEnumerable<TSource>, Func<TSource,IEnumerable<TResult>>)

將序列的每個項目都投影成 IEnumerable<T>,並將產生的序列簡化成單一序列。

SelectMany<TSource,TResult>(IEnumerable<TSource>, Func<TSource,Int32,IEnumerable<TResult>>)

將序列的每個項目都投影成 IEnumerable<T>,並將產生的序列簡化成單一序列。 各來源項目的索引是在該項目的投影表單中使用。

SelectMany<TSource,TCollection,TResult>(IEnumerable<TSource>, Func<TSource,IEnumerable<TCollection>>, Func<TSource,TCollection,TResult>)

將序列的每個項目投影為 IEnumerable<T>、將產生的序列簡化成單一序列,並對其中的每個項目叫用結果選取器函式。

SelectMany<TSource,TCollection,TResult>(IEnumerable<TSource>, Func<TSource,Int32,IEnumerable<TCollection>>, Func<TSource,TCollection,TResult>)

將序列的每個項目投影為 IEnumerable<T>、將產生的序列簡化成單一序列,並對其中的每個項目叫用結果選取器函式。 各來源項目的索引是在該項目的中繼投影表單中使用。

SequenceEqual<TSource>(IEnumerable<TSource>, IEnumerable<TSource>)

使用項目之型別的預設相等比較子來比較項目,以判斷兩個序列是否相等。

SequenceEqual<TSource>(IEnumerable<TSource>, IEnumerable<TSource>, IEqualityComparer<TSource>)

使用指定的 IEqualityComparer<T> 來比較項目,以判斷兩個序列是否相等。

Single<TSource>(IEnumerable<TSource>)

傳回序列的唯一一個元素,如果序列中不是正好一個元素,則擲回例外狀況。

Single<TSource>(IEnumerable<TSource>, Func<TSource,Boolean>)

傳回序列中符合指定之條件的唯一一個元素,如果有一個以上這類元素,則擲回例外狀況。

SingleOrDefault<TSource>(IEnumerable<TSource>)

傳回序列的唯一一個項目,如果序列是空白,則為預設值,如果序列中有一個以上的項目,這個方法就會擲回例外狀況。

SingleOrDefault<TSource>(IEnumerable<TSource>, Func<TSource,Boolean>)

傳回序列中符合指定之條件的唯一一個元素,如果沒有這類元素,則為預設值,如果有一個以上的元素符合條件,這個方法就會擲回例外狀況。

Skip<TSource>(IEnumerable<TSource>, Int32)

略過序列中指定的項目數目,然後傳回其餘項目。

SkipWhile<TSource>(IEnumerable<TSource>, Func<TSource,Boolean>)

只要指定的條件為 true,便略過序列中的項目,然後傳回其餘項目。

SkipWhile<TSource>(IEnumerable<TSource>, Func<TSource,Int32,Boolean>)

只要指定的條件為 true,便略過序列中的項目,然後傳回其餘項目。 項目的索引是用於述詞功能的邏輯中。

Sum<TSource>(IEnumerable<TSource>, Func<TSource,Decimal>)

計算在輸入序列中各項目上叫用轉換函式後所取得之 Decimal 值序列的總和。

Sum<TSource>(IEnumerable<TSource>, Func<TSource,Double>)

計算在輸入序列中各項目上叫用轉換函式後所取得之 Double 值序列的總和。

Sum<TSource>(IEnumerable<TSource>, Func<TSource,Int32>)

計算在輸入序列中各項目上叫用轉換函式後所取得之 Int32 值序列的總和。

Sum<TSource>(IEnumerable<TSource>, Func<TSource,Int64>)

計算在輸入序列中各項目上叫用轉換函式後所取得之 Int64 值序列的總和。

Sum<TSource>(IEnumerable<TSource>, Func<TSource,Nullable<Decimal>>)

計算在輸入序列中各項目上叫用轉換函式後所取得可為 Null 之 Decimal 值的總和。

Sum<TSource>(IEnumerable<TSource>, Func<TSource,Nullable<Double>>)

計算在輸入序列中各項目上叫用轉換函式後所取得可為 Null 之 Double 值的總和。

Sum<TSource>(IEnumerable<TSource>, Func<TSource,Nullable<Int32>>)

計算在輸入序列中各項目上叫用轉換函式後所取得可為 Null 之 Int32 值的總和。

Sum<TSource>(IEnumerable<TSource>, Func<TSource,Nullable<Int64>>)

計算在輸入序列中各項目上叫用轉換函式後所取得可為 Null 之 Int64 值的總和。

Sum<TSource>(IEnumerable<TSource>, Func<TSource,Nullable<Single>>)

計算在輸入序列中各項目上叫用轉換函式後所取得可為 Null 之 Single 值的總和。

Sum<TSource>(IEnumerable<TSource>, Func<TSource,Single>)

計算在輸入序列中各項目上叫用轉換函式後所取得之 Single 值序列的總和。

Take<TSource>(IEnumerable<TSource>, Int32)

從序列開頭傳回指定的連續項目數目。

TakeWhile<TSource>(IEnumerable<TSource>, Func<TSource,Boolean>)

只要指定的條件為 true,就會傳回序列中的項目。

TakeWhile<TSource>(IEnumerable<TSource>, Func<TSource,Int32,Boolean>)

只要指定的條件為 true,就會傳回序列中的項目。 項目的索引是用於述詞功能的邏輯中。

ToArray<TSource>(IEnumerable<TSource>)

IEnumerable<T> 建立陣列。

ToDictionary<TSource,TKey>(IEnumerable<TSource>, Func<TSource,TKey>)

根據指定的索引鍵選擇器函式,從 Dictionary<TKey,TValue> 建立 IEnumerable<T>

ToDictionary<TSource,TKey>(IEnumerable<TSource>, Func<TSource,TKey>, IEqualityComparer<TKey>)

根據指定的索引鍵選取器函式和索引鍵比較子,從 Dictionary<TKey,TValue> 建立 IEnumerable<T>

ToDictionary<TSource,TKey,TElement>(IEnumerable<TSource>, Func<TSource,TKey>, Func<TSource,TElement>)

根據指定的索引鍵選取器和項目選取器函式,從 Dictionary<TKey,TValue> 建立 IEnumerable<T>

ToDictionary<TSource,TKey,TElement>(IEnumerable<TSource>, Func<TSource,TKey>, Func<TSource,TElement>, IEqualityComparer<TKey>)

根據指定的索引鍵選取器函式、比較子和項目選取器函式,從 Dictionary<TKey,TValue> 建立 IEnumerable<T>

ToHashSet<TSource>(IEnumerable<TSource>)

IEnumerable<T> 建立 HashSet<T>

ToHashSet<TSource>(IEnumerable<TSource>, IEqualityComparer<TSource>)

使用比較金鑰的 comparerIEnumerable<T> 建立 HashSet<T>

ToList<TSource>(IEnumerable<TSource>)

IEnumerable<T> 建立 List<T>

ToLookup<TSource,TKey>(IEnumerable<TSource>, Func<TSource,TKey>)

根據指定的索引鍵選擇器函式,從 Lookup<TKey,TElement> 建立 IEnumerable<T>

ToLookup<TSource,TKey>(IEnumerable<TSource>, Func<TSource,TKey>, IEqualityComparer<TKey>)

根據指定的索引鍵選取器函式和索引鍵比較子,從 Lookup<TKey,TElement> 建立 IEnumerable<T>

ToLookup<TSource,TKey,TElement>(IEnumerable<TSource>, Func<TSource,TKey>, Func<TSource,TElement>)

根據指定的索引鍵選取器和項目選取器函式,從 Lookup<TKey,TElement> 建立 IEnumerable<T>

ToLookup<TSource,TKey,TElement>(IEnumerable<TSource>, Func<TSource,TKey>, Func<TSource,TElement>, IEqualityComparer<TKey>)

根據指定的索引鍵選取器函式、比較子和項目選取器函式,從 Lookup<TKey,TElement> 建立 IEnumerable<T>

Union<TSource>(IEnumerable<TSource>, IEnumerable<TSource>)

使用預設相等比較值來比較值,以便產生兩個序列的集合等位。

Union<TSource>(IEnumerable<TSource>, IEnumerable<TSource>, IEqualityComparer<TSource>)

使用指定的 IEqualityComparer<T> 產生兩個序列的集合等位。

Where<TSource>(IEnumerable<TSource>, Func<TSource,Boolean>)

根據述詞來篩選值序列。

Where<TSource>(IEnumerable<TSource>, Func<TSource,Int32,Boolean>)

根據述詞來篩選值序列。 述詞函式的邏輯中使用各項目的索引。

Zip<TFirst,TSecond,TResult>(IEnumerable<TFirst>, IEnumerable<TSecond>, Func<TFirst,TSecond,TResult>)

將指定的函式套用至兩個序列的對應項目,產生結果的序列。

AsParallel(IEnumerable)

啟用查詢的平行化作業。

AsParallel<TSource>(IEnumerable<TSource>)

啟用查詢的平行化作業。

AsQueryable(IEnumerable)

IEnumerable 轉換成 IQueryable

AsQueryable<TElement>(IEnumerable<TElement>)

將泛型 IEnumerable<T> 轉換成泛型 IQueryable<T>

Ancestors<T>(IEnumerable<T>)

傳回包含來源集合中每個節點祖系的項目集合。

Ancestors<T>(IEnumerable<T>, XName)

傳回包含來源集合中每個節點祖系的已篩選項目集合。 集合中只會包含具有相符之 XName 的項目。

DescendantNodes<T>(IEnumerable<T>)

傳回來源集合中每個文件和項目之子代節點的集合。

Descendants<T>(IEnumerable<T>)

傳回包含來源集合中每個項目和文件之子代項目的項目集合。

Descendants<T>(IEnumerable<T>, XName)

傳回已篩選的項目集合,其中包含來源集合中每個項目和文件的子代項目。 集合中只會包含具有相符之 XName 的項目。

Elements<T>(IEnumerable<T>)

傳回來源集合中每個項目和文件的子項目集合。

Elements<T>(IEnumerable<T>, XName)

傳回來源集合中每個項目和文件的已篩選子項目集合。 集合中只會包含具有相符之 XName 的項目。

InDocumentOrder<T>(IEnumerable<T>)

傳回包含來源集合中所有節點的節點集合,依據文件順序來排序。

Nodes<T>(IEnumerable<T>)

傳回來源集合中每個文件和項目的子節點集合。

Remove<T>(IEnumerable<T>)

在來源集合中,從每一個節點的父節點移除這些節點。

適用於