Code Snippet: Implementing a ChangedIdEnumerator

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 ChangedIdEnumerator method instance in a .NET connectivity assembly and in a Web service.

Example for a .NET Connectivity Assembly

public CustomerVersion[] GetCustomerChangedIDs(String[] ids)
{
    List<CustomerVersion> custverList = new List<CustomerVersion>();
    foreach (Customer customer in customers)
    {
        if (Array.Find(ids, id => 
            id == customer.CustomerID && !customer.IsDeleted) != null)
        {
            custverList.Add(new CustomerVersion() 
            { 
                CustomerID = customer.CustomerID, 
                Version = customer.Version 
            });
        }
    }
    return custverList.ToArray();
}

Example for an ASP.NET Web Service

[WebMethod]
public CustomerVersion[] GetCustomerChangedIDs(String[] ids)
{
    List<CustomerVersion> custverList = new List<CustomerVersion>();
    foreach (Customer customer in customers)
    {
        if (Array.Find(ids, id => 
            id == customer.CustomerID && !customer.IsDeleted) != null)
        {
            custverList.Add(new CustomerVersion() 
            { 
                CustomerID = customer.CustomerID, 
                Version = customer.Version 
            });
        }
    }
    return custverList.ToArray();
}

Example for a WCF Service

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

[OperationContract]
CustomerVersion[] GetCustomerChangedIDs(string[] ids);

The following example shows the implementation of the method instance.

public CustomerVersion[] GetCustomerChangedIDs(String[] ids)
{
    List<CustomerVersion> custverList = new List<CustomerVersion>();
    foreach (Customer customer in customers)
    {
        if (Array.Find(ids, id => 
            id == customer.CustomerID && !customer.IsDeleted) != null)
        {
            custverList.Add(new CustomerVersion() 
            { 
                CustomerID = customer.CustomerID, 
                Version = customer.Version 
            });
        }
    }
    return custverList.ToArray();
}

See Also

Concepts

Implementing a ChangedIdEnumerator