편집

다음을 통해 공유


Projection - Operation Combine Attributes

Overview

CombineAttributes is a projection operation that allows you to merge multiple input attribute into one. This operation takes a list of attributes on the select property and replace them with the data typed attribute supplied on the mergeInto property. If the list of attributes to be merged is empty, this operation does not have any effect.

Note: you can access the API reference for this operation on this link.

Examples

The examples below refer to the ContactKinds entity as defined here.

{
    "entityName": "ContactKinds",
    "hasAttributes": [
        {
            "name": "emailKind",
            "entity": "Email"
        },
        { 
            "name": "phoneKind", 
            "entity": "Phone"
        },
        {
            "name": "socialKind",
            "entity": "Social"
        }
    ]
}
Email Phone Social
emailId phoneId socialId
address number account
isPrimary isPrimary isPrimary

Using the CombineAttributes operation on an entity attribute

If we have an entity attribute, we can use CombineAttributes to merge certain attributes we get from the referenced entity.

{
    "name": "contactAt",
    "isPolymorphicSource": true,
    "entity": {
        "operations": [
            {
                "$type": "combineAttributes",
                "select": ["emailId", "phoneId", "socialId"],
                "mergeInto": {
                    "name": "contactId",
                    "dataType": "entityId"
                }
            }
        ],
        "source": "ContactKinds"
    }
}

The resulting resolved contactAt entity typed attribute is:

contactAt
address
isPrimary
number
account
contactId
contactType

Using the CombineAttributes operation when extending an entity

If we have an entity that extends another entity, we can use CombineAttributes to merge certain attributes that are inherited from the entity we are extending from.

Given an entity, Child, that extends from the Person entity:

{
    "entityName": "Customer",
    "extendsEntity": {
        "operations": [
            {
                "$type": "combineAttributes",
                "select": [ "emailId", "phoneId", "socialId" ],
                "mergeInto": {
                    "name": "contactId",
                    "dataType": "entityId"
                }
            }
        ],
        "source": "ContactKinds"
    },
    "hasAttributes": []
}

The resulting resolved Customer entity is:

Customer
address
isPrimary
number
account
contactId