IErpEntityType Interface
Provides the interface holding data about the EntityType.
Namespace: powerGate.Erp.Client
Assembly: powerGate.Erp.Client.dll
Syntax
1 | public interface IErpEntityType |
Properties
Type |
Name |
Description |
---|---|---|
EntitySet |
Gets the EntitySet of the EntityType. |
|
Service |
Gets the EntitySet of the Service. |
|
string |
Name |
The name of the EntityType. |
string |
Namespace |
The namespace of the EntityType. |
Keys |
Gets the Key properties which uniquely identifies the EntityType. |
|
Properties |
Gets the properties for the EntityType. |
|
Navigationproperties |
Gets the navigation properties for the EntityType. |
Methods
Type |
Name |
Description |
---|---|---|
NewErpObject() |
Creates a new and empty ErpObject instance of the current EntityType. The properties will be filled with the default values. |
Remarks
The property EntitySet returns the EntitySet where this EntityType is assigned to. Some EntityTypes are not assigned to an EntitySet an the property will return Null for them.
The NewErpObject() creates a new ErpObject instance of the current EntityType, by analyzing the $metadata for required and optional Properties and NavigationProperties.
The properties will be filled with the default values (see __DefaultValue__ in Property). For nullable properties (see IsNullable in Property) the value will be null.
For NavigationProperties with a target Multiplicity of One, the function is able to create the required target instance as well (recursive on multiple levels).
NavigationProperties can therefore safely be casted to type ErpObject or type Dictionary<string,object> (or IEnumerable of the described Type when they are collections).
Examples
In the following examples we are using public OData Services (http://services.odata.org) for demonstration purposes:
Create a new empty ErpObject instance
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 powerGate.Erp.Client; namespace EntityTypeSample { class Program { static void Main(string[] args) { using (var erpclient = new ErpClient()) { using (var service = erpclient.ConnectErp(new Uri("http://services.odata.org/V3/Northwind/Northwind.svc"))) { //Get the Territory EntityType var entityType = service.EntityTypes["NorthwindModel.Territory"]; //Create a new empty ErpObject instance from the Territory EntityType var territory = entityType.NewErpObject(); Console.Write("Region ID: {0}", territory["RegionID"]); } } } } } |
See also
Reference