简体   繁体   中英

Avoiding duplicates in parent scope when mapping field in Biztalk Map

My situation is like this: A "Code" field from the source tree, needs to be mapped to a "Code" field in the destination tree. The "Code" field in the destination tree has 2 parent nodes. For the destination schema to validate, the same code must not occur more than once in the scope of the 2nd parent node. Here's an image of the hiearchy:

在此处输入图片说明

So within the scope of "PurchaseInformation", no same "Code" may occur. A looping functoid loops on "GoodsDescription". I've tried to create an inline C# script to handle it, but it doesn't take the scope into account. See code below:

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

    public bool IsDuplicate(string code)
    {
         if( duplicateList.Contains(code)) {
            return false;
         } 
         else {
            duplicateList.Add(code);
            return true;
         }
    }

My problem is the global List that is created. It does not reset after each loop, but I'm unsure how to implement this functionality. My question is how I can make sure no duplicate codes are mapped within the scope of the "PurchaseInformation" record in the destination tree?

Without seeing the whole process, it's difficult to give what might be the best solution...but...

Instead of trying to reset the collection (there are reasons this is difficult) you might try a list of lists instead.

Presuming SimplifiedInvoice is an ID or something, you can use a Dictionary of Lists which will track lists of unique Code values per Invoice.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM