Complex Data Type Return Types in Operations

Actions

OData Actions can have complex typed return types. But it needs to be noted that there is a limitation.

Primitive Arrays are not supported in Complex Return types

When returning a complex data type from an operation (function or action), arrays of primitive and enumeration types are not supported inside the complex return type in any level. Arrays of complex types are supported though.

Examples

Supported

{
    "RootAlpha": "Alpha1",
    "RootBoolean": true,
    "RootDate": "2018-10-01",
    "Children": [
        {
            "Level1Integer": 1,
            "Level1Enum": "Car",
            "Child": {
                "Level2Number": 1.95,
                "Level2Text": "Text1"
            }
        },
        {
            "Level1Integer": 3,
            "Level1Enum": "Suv",
            "Child": {
                "Level2Number": 3.69,
                "Level2Text": "Text2"
            }
        }
    ]
}

Marble Code

structure RootStruct {
    attribute RootAlpha Alpha;
    attribute RootBoolean Boolean;
    attribute RootDate Date;
    attribute Child List<Structure(Level1Struct)>;
}

structure Level1Struct { attribute Level1Integer Integer; attribute Level1Enum Enumeration(VehicleType); attribute Child Structure(Level2Struct); }
structure Level2Struct { attribute Level2Number Number; attribute Level2Text Text; }

Example code - Valid Marble structure

Not Supported

{
    "RootAlpha": "Alpha1",
    "RootBoolean": true,
    "RootDate": "2018-10-01",
    "RootNumArray": [ 1, 20, 24, 45 ],
    "RootTextArray": [ "Text1", "Text2", "Text3" ]
}

Marble Code

structure {
    attribute RootAlpha Alpha;
    attribute RootBoolean Boolean;
    attribute RootDate Date;
    attribute RootNumArray List<Number>;
    attribute RootTextArray List<Text>;
}

Example code - Invalid Marble structure

Functions

OData Functions only supports single level complex structures. That is, functions cannot have Complex return type where it has attributes of Arrays or Complex data types.

Examples

Supported

{
    "RootAlpha": "Alpha1",
    "RootBoolean": true,
    "RootDate": "2018-10-01",
}

Marble Code

structure RootStruct {
    attribute RootAlpha Alpha;
    attribute RootBoolean Boolean;
    attribute RootDate Date;
}

Example code - Marble structure valid function

Not Supported

{
    "RootAlpha": "Alpha1",
    "RootBoolean": true,
    "RootDate": "2018-10-01",
    "Children": [
        {
            "Level1Integer": 1,
            "Level1Enum": "Car",
            "Child": {
                "Level2Number": 1.95,
                "Level2Text": "Text1"
            }
        }
    ]
}

Marble Code

structure RootStruct {
    attribute RootAlpha Alpha;
    attribute RootBoolean Boolean;
    attribute RootDate Date;
    attribute Child List<Structure(Level1Struct)>;
}

structure Level1Struct { attribute Level1Integer Integer; attribute Level1Enum Enumeration(VehicleType); attribute Child Structure(Level2Struct); }
structure Level2Struct { attribute Level2Number Number; attribute Level2Text Text; }

Example code - Marble structure invalid function

Back