How to avoid mapping duplicates in a BizTalk Map

In a BizTalk Map, you can avoid mapping the duplicates of the same item/key by using a List collection. Each time you map an item, you check to see if it is in the list. If is in the list, you return a “false” and if it is not in the list, you add it to the list.

<pre>
public System.Collections.Generic.List<string> duplicateList = new System.Collections.Generic.List<string>();

public bool IsDuplicate( string invoiceHeaderNumber)
{
     if( duplicateList.Contains( invoiceHeaderNumber))
        return true;
     duplicateList.Add( invoiceHeaderNumber);
     return false;
}
</pre>

Below shows how this is “wired-up”. You put the C# code in a Scripting Functoid as inline C# script.

In this example, SQL typed-polling was used to send data to an orchestration. In the orchestration, the above map was called to call a second stored procedure, where the need was to not process duplicates.

NOTE: When you set an outgoing item on a map to the value of “false”, then that item will not be mapped (for this iteration).