--- myst: substitutions: method: |- ```{image} /img/code_reference/net_library/method.ico ``` prop: |- ```{image} /img/code_reference/net_library/prop.ico ``` --- # IErpEntitySet Interface Provides the interface for working with an EntitySet: Adding, Getting, Updating and/or Removing entities. : \ **Namespace:** powerGate.Erp.Client\ **Assembly:** powerGate.Erp.Client.dll ## Syntax ```{code-block} CSharp :linenos: public interface IErpEntitySet ``` ## Properties | Type | Name | Description | |----------------------------------------------|-----------------------|--------------------------------------------------------------------------------| | {{prop}} [IErpEntityType]() | EntityType | Gets the EntityType of the EntitySet. | | {{prop}} [IMediaResources]() | MediaResources | Gets the instance of IMediaResources to Add, Get and/or Update MediaResources. | | {{prop}} string | Name | The name of the EntitySet. | | {{prop}} [IErpService]() | Service | Gets the service of the EntitySet. | | {{prop}} bool | SupportMediaResources | Indicates whether the EntitySet supports MediaResources. | ## Methods | Type | Name | Description | |-----------------------------------------|------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------| | {{method}} [ErpObject][] | AddErpObject(Dictionary\ properties) | Creates a new ErpObject for the EntitySet in the ERP-System. | | {{method}} [ErpObject][] | GetErpObject([SearchOptions][] options) | Retrieves the specified ErpObject from the ERP-System | | {{method}} IEnumerable\<[ErpObject][]\> | GetErpObjects([QueryOptions][] options) | Searches for ErpObject's depending on the passed options in the ERP-System. | | {{method}} void | RemoveErpObject(Dictionary\ keys) | Removes the specified ErpObject from the EntitySet in the ERP-System. | | {{method}} [ErpObject][] | UpdatErpObject(Dictionary\ keys, Dictionary\ properties) | Updates the specified ErpObject for the EntitySet in the ERP-System. | [ErpObject]: erpobject [SearchOptions]: searchoptions [QueryOptions]: queryoptions ## Extension Methods | Type | Name | Description | |---------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------| | {{method}} [ErpObject]() | GetErpObject(Dictionary\ keys, IEnumerable\ expand = null, IEnumerable\ select = null) | Overloaded. Retrieves the specified ErpObject from the ERP-System using the specified parameter values. | | {{method}} IEnumerable\<[ErpObject]()\> | GetErpObjects(string filter = null, int top = 0, IEnumerable\ expand = null, IEnumerable\ select = null, IEnumerable\<[OrderBy]()\> orderBy = null) | Overloaded. Searches for ErpObject's from the ERP-System using the specified parameter values. | ## Exceptions In case of an invalid request the above methods will throw a [WebRequestException](). ## Remarks The property **MediaResources** con only be used on EntitySets that are supporting streaming. ## Examples In the following examples we are using public OData Services () for demonstration purposes: **Add a new ErpObject** ```{code-block} CSharp :linenos: using System; using System.Collections.Generic; using powerGate.Erp.Client; namespace EntitySetSample { class Program { static void Main(string[] args) { using (var erpclient = new ErpClient()) { using (var service = erpclient.ConnectErp(new Uri("http://services.odata.org/V3/OData/OData.svc"))) { var products = service.EntitySets["Products"]; //Add a new ErpObject var orangeJuice = products.AddErpObject(new Dictionary { {"ID", 5}, {"Name", "Orange Juice"}, {"Description", "The original Orange Juice. Refreshing!"}, {"ReleaseDate", "2006-08-04T00 ,00 ,00Z"}, {"DiscontinuedDate", null}, {"Rating", 3}, {"Price", 22.8} }); Console.Write("Created new Product: {0}", orangeJuice["Name"]); } } } } } ``` **Get a specific ErpObject** ```{code-block} CSharp :linenos: using System; using System.Collections.Generic; using powerGate.Erp.Client; namespace EntitySetSample { class Program { static void Main(string[] args) { using (var erpclient = new ErpClient()) { using (var service = erpclient.ConnectErp(new Uri("http://services.odata.org/V4/Northwind/Northwind.svc"))) { var categories = service.EntitySets["Categories"]; //Get the customer with ID CACTU var category = categories.GetErpObject(new SearchOptions { Keys = new Dictionary { { "CategoryID", 1 } }, Expand = new[] { "Products" }, Select = new[] { "CategoryID" } }); Console.Write("Category ID: {0}", category["CategoryID"]); } } } } } ``` **Search for ErpObject's with a filter** ```{code-block} CSharp :linenos: using System; using System.Collections.Generic; using powerGate.Erp.Client; namespace EntitySetSample { 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/"))) { var customers = service.EntitySets["Customers"]; //Get all customers with a company starting with 'A' var foundCustomers = customers.GetErpObjects(filter: "startswith(CompanyName,'A')"); foreach (var customer in foundCustomers) Console.Write("Customer {0} with Company {1}", customer["CustomerID"], customer["CompanyName"]); } } } } } ``` **Remove an ErpObject** ```{code-block} CSharp :linenos: using System; using System.Collections.Generic; using powerGate.Erp.Client; namespace EntitySetSample { class Program { static void Main(string[] args) { using (var erpclient = new ErpClient()) { using (var service = erpclient.ConnectErp(new Uri("http://services.odata.org/V3/OData/OData.svc"))) { var products = service.EntitySets["Products"]; //Remove Product with ID '1' products.RemoveErpObject(new Dictionary { { "ID", 1 } }); } } } } } ``` **Update an ErpObject** ```{code-block} CSharp :linenos: using System; using System.Collections.Generic; using powerGate.Erp.Client; namespace EntitySetSample { class Program { static void Main(string[] args) { using (var erpclient = new ErpClient()) { using (var service = erpclient.ConnectErp(new Uri("http://services.odata.org/V3/OData/OData.svc"))) { var products = service.EntitySets["Products"]; //Get Product to update var product = products.GetErpObject(new Dictionary { { "ID", 9 } }); //Updating Rating and Price properties var updatedProduct = products.UpdatErpObject(product.GetKeys(), new Dictionary { { "Rating", 9 }, { "Price", 1.99 } }); Console.Write("New Price: {0}", updatedProduct["Price"]); } } } } } ``` ## See also **Reference** - [powerGate.Erp.Client namespace]() - [Add-ERPObject cmdlet]() - [Get-ERPObject cmdlet]() - [Get-ERPObjects cmdlet]() - [Remove-ERPObject cmdlet]() - [Update-ERPObject cmdlet]()