Configuration Container With Multiple Entities Message

The Connector you develop using the Messaging Framework must be able to parse messages received from the sending API. To parse the message, the Connector must understand the data structure for each message object. You can use a sample message from the sending API to configure the code that parses the inbound message by pasting the sample message as JSON in the item.cs file in your project and modifying the Connector.cs file to match the changes in item.cs. See Creating Message Classes for step-by-step instructions on pasting a message into your project.

This scenario can be very similar to the Configuration Container With Single Entity Message scenario, but also offers many variations.

If the message received from the third-party API is configured such that the entire message is a container with multiple entities, note the following: 

In JSON the message might look like:

{
    "AccountName""Acme, Inc.",
    "Contacts": [
        {
            "FirstName""Abby",
            "LastName""Aaron"
        },
        {
            "FirstName""Bob",
            "LastName""Burr"
        }
    ]
}

If this is the message received and you are interested in the Person data, you have the Account as the container and then more than one person. If you paste JSON as Classes you start with:

public class Account
{
    public string AccountName { getset; }
    public Person[] Contacts { getset; }
}
public class Person
{
    public string FirstName { getset; }
    public string LastName { getset; }
}

Modify the Connector.cs file to recognize the change made in the item.cs file. Here you want a lambda or function that takes an account and returns multiple Persons. In .NET this would be something that implements IEnumerable<Person>, such as an Array, or [].

protected override IDictionary<stringMessageDescription> RegisterEntities()
{
    return this.Start
        .RegisterArray<AccountPerson>(account => account.Contacts);
}

There is an overload that determines what to do based on whether the lambda or function returns an enumerable of Person or just a single Person or whatever the second Type Parameters use.

See

Building A Messaging Framework Connector