ErpObject Class

Represents an ERP entity or complex type and provides access to its properties and values.

Namespace: powerGate.Erp.Client
Assembly: powerGate.Erp.Client.dll

Inheritance Hierarchy

System.Object
 System.Collections.Generic.Dictionary<string, object>
  powerGate.Erp.Client.ErpObject

Syntax

1
public class ErpObject : Dictionary<string, object>

The ErpObject type exposes the following members.

Properties

Type

Name

Description

../../../_images/prop.ico IErpEntityType

EntityType

Gets the underlying entity type definition.

Methods

Type

Name

Description

../../../_images/method.ico Dictionary<string, object>

GetKeys()

Returns only the Key properties that uniquely identify an entity in ERP.
Note: Keys referencing properties of complex types are returned using their alias names.

../../../_images/method.ico Dictionary<string, object>

GetProperties()

Returns all other properties (except keys) and their values.
This includes simple properties, complex type properties, and even navigation properties.

../../../_images/method.ico object

InvokeErpOperation(string operationName, Dictionary<string, object> parameters = null, string property = null)

Invokes a bound OData action or function with the specified name using this entity’s keys and, optionally, an additional property or navigation path. Additional parts of the namespace can be included in operationName.

Remarks

Based on the type definition from the ERP system’s $metadata, the ErpObject provides all properties defined in the ERP with their names and values.

Simple property values are returned using their corresponding .NET types, while complex type- and navigation properties are returned as nested ErpObject Class instances.

The InvokeErpOperation() method invokes a bound OData action or function on this entity. The optional property argument is a resource path, such as Trips or Trips(0)/Details.

Complex Types do not have Keys

Please note that the GetKeys() function does not return any keys for complex type instances.

According to the OData specification, only entity types define keys. Complex types are therefore actually not true “entities”, even though they share many of the same characteristics.

The GetKeys() and GetProperties() functions return a readonly Dictionary containing a subset of properties and values that cannot be modified.
However, any modifications made to the ErpObject are reflected in the results returned by both functions.

Examples

Invoking a bound function through a navigation property

The following example invokes the GetInvolvedPeople function on the first trip of a person.
The property argument continues the resource path from the person through Trips(0):

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
using System;
using System.Collections.Generic;
using powerGate.Erp.Client;

namespace ErpObjectSample
{
  class Program
  {
    static void Main(string[] args)
    {
      using (var erpclient = new ErpClient()){
        using (var service = erpclient.ConnectErp(new Uri("https://services.odata.org/TripPinRESTierService/")))
        {
           var people = service.EntitySets["People"];
           var person = people.GetErpObject(new Dictionary<string, object> { { "UserName", "russellwhyte" } });
           var involvedPeople = person.InvokeErpOperation("Trippin.GetInvolvedPeople", property: "Trips(0)");
           Console.WriteLine(involvedPeople);
        }
      }
    }
  }
}

See also

Reference