IErpEntitySet Interface
Provides the interface for working with an EntitySet: retrieving, adding, updating and/or removing entities.
Namespace: powerGate.Erp.Client
Assembly: powerGate.Erp.Client.dll
Syntax
1 | public interface IErpEntitySet |
Properties
Type |
Name |
Description |
|---|---|---|
EntityType |
Gets the EntityType of the EntitySet. |
|
MediaResources |
Gets the instance of IMediaResources to Add, Get and/or Update MediaResources. |
|
|
Name |
The name of the EntitySet. |
Service |
Gets the service of the EntitySet. |
|
|
SupportMediaResources |
Indicates whether the EntitySet supports MediaResources. |
Methods
Type |
Name |
Description |
|---|---|---|
AddErpObject(Dictionary<string,object> properties) |
Creates a new entity in the ERP-System. |
|
GetErpObject(SearchOptions options) |
Retrieves the specified entity from the ERP-System |
|
|
GetErpObjects(QueryOptions options) |
Searches for ERP entities depending on the passed options. |
|
RemoveErpObject(Dictionary<string,object> keys) |
Removes the specified entity in the ERP-System. |
UpdateErpObject(Dictionary<string,object> keys, Dictionary<string,object> properties) |
Updates properties of the specified entity in the ERP-System. |
|
|
InvokeErpOperation(string operationName, Dictionary<string,object> parameters = null, Dictionary<string,object> keys = null, string property = null) |
Invokes a bound OData action or function with the specified name, parameters, entity keys, and optional property or navigation path. Additional parts of the namespace can be included in |
Extension Methods
Type |
Name |
Description |
|---|---|---|
GetErpObject(Dictionary<string,object> keys, IEnumerable<string> expand = null, IEnumerable<string> select = null) |
Overloaded. Retrieves the specified entity from the ERP-System using the specified parameter values. |
|
|
GetErpObjects(string filter = null, int top = 0, IEnumerable<string> expand = null, IEnumerable<string> select = null, IEnumerable<OrderBy> orderBy = null) |
Overloaded. Searches for ERP entities using the specified parameter values. |
Exceptions
In case of an invalid request the above methods will throw a WebRequestException.
Remarks
The property MediaResources can only be used on EntitySets that are supporting streaming.
Examples
In the following examples we are using public OData Services (http://services.odata.org) for demonstration purposes:
Adding a Product with simple properties in the ERP system
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | 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"]; var entity = products.AddErpObject(new Dictionary<string, object> { {"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}", entity["Name"]); } } } } } |
Retrieving a specific ERP entity including navigation property details
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | 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"]; var category = categories.GetErpObject( new Dictionary<string, object> { { "CategoryID", 1 } }, expand: new[] { "Products" }); Console.Write($"Category ID: {category["CategoryID"]}"); var products = category["Products"] as IEnumerable<ErpObject>; Console.Write($"Products: {products.Count()}"); } } } } } |
Searching for entities in ERP, ordered by properties of a Complex Type
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | 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/OData/(S(fa2g1e4kjczcfnog0asxmvhh))/OData.svc"))) { var suppliers = service.EntitySets["Suppliers"]; //Get all suppliers starting with 'A'; var foundSuppliers = suppliers.GetErpObjects( filter: "startswith(Name,'A')", orderBy: new[] { new OrderBy("Address/Country"), new OrderBy("Address/City", OrderDirection.Descending) // Path to a property of a Complex Type. }); foreach (var supplier in foundSuppliers) Console.Write("Supplier: {0}", supplier["Name"]); } } } } } |
Remove an ErpObject
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 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<string, object> { { "ID", 1 } }); } } } } } |
Updating a single property of an ERP entity
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | 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://localhost:8080/pgs/ERP/MaterialService/"))) { var materials = service.EntitySets["Materials"]; var material = materials.UpdatErpObject( new Dictionary<string, object> { { "Number", "3169" } }, new Dictionary<string, object> { { "Type", "updated Type" } }); var materialDescriptions = service.EntitySets["MaterialDescriptions"]; var description = materialDescriptions.UpdatErpObject( new Dictionary<string, object> { { "Number", "3169" }, { "Language", "EN" } }, new Dictionary<string, object> { { "Description", "changed by powerGate" } }); // Instead of updating the Description through the Material entity's navigation property, the referenced MaterialDescription entity is updated separately. } } } } } |
Invoking a bound function on an entity or navigation property
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | 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("https://services.odata.org/TripPinRESTierService/"))) { var people = service.EntitySets["People"]; var trips = people.InvokeErpOperation( "Trippin.GetFriendsTrips", keys: new Dictionary<string, object> { { "UserName", "russellwhyte" } }, property: "Trips(0)"); Console.WriteLine(trips); } } } } } |
See also
Reference