--- myst: substitutions: method: |- ```{image} /img/code_reference/net_library/method.ico ``` prop: |- ```{image} /img/code_reference/net_library/prop.ico ``` --- # IErpEntityType Interface Provides the interface holding data about the EntityType. **Namespace:** powerGate.Erp.Client\ **Assembly:** powerGate.Erp.Client.dll ## Syntax ```{code-block} CSharp :linenos: public interface IErpEntityType ``` ## Properties | Type | Name | Description | |---------------------------------------|----------------------|-------------------------------------------------------------------| | {{prop}} [IErpEntitySet][] | EntitySet | Gets the EntitySet of the EntityType. | | {{prop}} [IErpService][] | Service | Gets the EntitySet of the Service. | | {{prop}} string | Name | The name of the EntityType. | | {{prop}} string | Namespace | The namespace of the EntityType. | | {{prop}} [IErpProperties][] | Keys | Gets the Key properties which uniquely identifies the EntityType. | | {{prop}} [IErpProperties][] | Properties | Gets the properties for the EntityType. | | {{prop}} [IErpNavigationProperties][] | Navigationproperties | Gets the navigation properties for the EntityType. | ## Methods | Type | Name | Description | |--------------------------|----------------|----------------------------------------------------------------------------------------------------------------------------------| | {{method}} [ErpObject][] | NewErpObject() | Creates a new and empty [ErpObject][] instance of the current EntityType. The properties will be filled with the default values. | [IErpEntitySet]: ierpentityset [IErpService]: ierpservice [IErpProperties]: ierpproperties [IErpNavigationProperties]: ierpnavigationsproperties [ErpObject]: erpobject ## 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\ (or IEnumerable of the described Type when they are collections). ## Examples In the following examples we are using public OData Services () for demonstration purposes: **Create a new empty ErpObject instance** ```{code-block} CSharp :linenos: 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** - [powerGate.Erp.Client namespace]() - [New-ERPObject cmdlet]()