Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
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 BulkAssociationNavigator method instance in a .NET connectivity assembly and in a Web service.
Example for a .NET Connectivity Assembly
public Order[] GetBulkOrdersForCustomers(string[] custids)
{
    if (custids == null)
    {
        return orders.ToArray();
    }
    else
    {
        List<Order> ordersForCustomer = new List<Order>();
        foreach (Order order in orders)
        {
            if (Array.Find(
                custids, id => id == order.CustomerID) != null)
            {
                ordersForCustomer.Add(order);
            }
        }
        return ordersForCustomer.ToArray();
    }
}
Example for an ASP.NET Web Service
[WebMethod] 
public Order[] GetBulkOrdersForCustomers(string[] custids)
{
    if (custids == null)
    {
        return orders.ToArray();
    }
    else
    {
        List<Order> ordersForCustomer = new List<Order>();
        foreach (Order order in orders)
        {
            if (Array.Find(
                custids, id => id == order.CustomerID) != null)
            {
                ordersForCustomer.Add(order);
            }
        }
        return ordersForCustomer.ToArray();
    }
}
Example for a WCF Service
The following code shows the operation definition in the service contract interface.
[OperationContract]
Order[] GetBulkOrdersForCustomers(string[] custids);
The following example shows the implementation of the method instance.
public Order[] GetBulkOrdersForCustomers(string[] custids)
{
    if (custids == null)
    {
        return orders.ToArray();
    }
    else
    {
        List<Order> ordersForCustomer = new List<Order>();
        foreach (Order order in orders)
        {
            if (Array.Find(
                custids, id => id == order.CustomerID) != null)
            {
                ordersForCustomer.Add(order);
            }
        }
        return ordersForCustomer.ToArray();
    }
}