代码段:实现 BulkAssociatedIdEnumerator

上次修改时间: 2010年4月19日

适用范围: SharePoint Server 2010

本文内容
.NET 连接程序集的示例
ASP.NET Web 服务的示例
WCF 服务的示例

以下代码示例演示如何在 .NET 连接程序集和 Web 服务中实现 BulkAssociatedIdEnumerator 方法实例。

.NET 连接程序集的示例

public CustomerOrder[] GetCustomerIdsByOrdersIds(String[] orderids)
{
    List<CustomerOrder> custordList = new List<CustomerOrder>();
    foreach (Order order in orders)
    {
        if (Array.Find(orderids, id => id == order.OrderID) != null)
        {
            custordList.Add(new CustomerOrder() 
            { CustomerID = order.CustomerID, OrderID = order.OrderID });
        }
    }
    return custordList.ToArray();
}

ASP.NET Web 服务的示例

[WebMethod]
public CustomerOrder[] GetCustomerIdsByOrdersIds(String[] orderids)
{
    List<CustomerOrder> custordList = new List<CustomerOrder>();
    foreach (Order order in orders)
    {
        if (Array.Find(orderids, id => id == order.OrderID) != null)
        {
            custordList.Add(new CustomerOrder() 
            { CustomerID = order.CustomerID, OrderID = order.OrderID });
        }
    }
    return custordList.ToArray();
}

WCF 服务的示例

以下代码演示服务约定接口中的操作定义。

[OperationContract]
CustomerOrder[] GetCustomerIdsByOrdersIds(String[] orderids);

以下示例演示该方法实例的实现。

public CustomerOrder[] GetCustomerIdsByOrdersIds(String[] orderids)
{
    List<CustomerOrder> custordList = new List<CustomerOrder>();
    foreach (Order order in orders)
    {
        if (Array.Find(orderids, id => id == order.OrderID) != null)
        {
            custordList.Add(new CustomerOrder() 
            { CustomerID = order.CustomerID, OrderID = order.OrderID });
        }
    }
    return custordList.ToArray();
}

请参阅

概念

实现 BulkAssociatedIdEnumerator