다음을 통해 공유


Code Snippet: Implementing a BulkAssociatedIdEnumerator

Applies to: SharePoint Server 2010

In this article
Example for a .NET Connectivity Assembly
Example for an ASP.NET Web Service
Example for a WCF Service

The following code examples show how you can implement a BulkAssociatedIdEnumerator method instance in a .NET connectivity assembly and in a Web service.

Example for a .NET Connectivity Assembly

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();
}

Example for an ASP.NET Web Service

[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();
}

Example for a WCF Service

The following code shows the operation definition in the service contract interface.

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

The following example shows the implementation of the method instance.

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();
}

See Also

Concepts

Implementing a BulkAssociatedIdEnumerator