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

1
public interface IErpEntitySet

Properties

Type

Name

Description

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

EntityType

Gets the EntityType of the EntitySet.

../../../_images/prop.ico IMediaResources

MediaResources

Gets the instance of IMediaResources to Add, Get and/or Update MediaResources.

../../../_images/prop.ico string

Name

The name of the EntitySet.

../../../_images/prop.ico IErpService

Service

Gets the service of the EntitySet.

../../../_images/prop.ico bool

SupportMediaResources

Indicates whether the EntitySet supports MediaResources.

Methods

Type

Name

Description

../../../_images/method.ico ErpObject

AddErpObject(Dictionary<string,object> properties)

Creates a new ErpObject for the EntitySet in the ERP-System.

../../../_images/method.ico ErpObject

GetErpObject(SearchOptions options)

Retrieves the specified ErpObject from the ERP-System

../../../_images/method.ico IEnumerable<ErpObject>

GetErpObjects(QueryOptions options)

Searches for ErpObject’s depending on the passed options in the ERP-System.

../../../_images/method.ico void

RemoveErpObject(Dictionary<string,object> keys)

Removes the specified ErpObject from the EntitySet in the ERP-System.

../../../_images/method.ico ErpObject

UpdatErpObject(Dictionary<string,object> keys, Dictionary<string,object> properties)

Updates the specified ErpObject for the EntitySet in the ERP-System.

Extension Methods

Type

Name

Description

../../../_images/method.ico ErpObject

GetErpObject(Dictionary<string,object> keys, IEnumerable<string> expand = null, IEnumerable<string> select = null)

Overloaded. Retrieves the specified ErpObject from the ERP-System using the specified parameter values.

../../../_images/method.ico IEnumerable<ErpObject>

GetErpObjects(string filter = null, int top = 0, IEnumerable<string> expand = null, IEnumerable<string> 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 (http://services.odata.org) for demonstration purposes:

Add a new ErpObject

 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
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<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}", orangeJuice["Name"]);
	                        }
	                }
	        }
	}
}

Get a specific ErpObject

 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
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<string, object> { { "CategoryID", 1 } },
	                                        Expand = new[] { "Products" },
	                                        Select = new[] { "CategoryID" }
	                                });
	                                Console.Write("Category ID: {0}", category["CategoryID"]);
	                        }
	                }
	        }
	}

}

Search for ErpObject’s with a filter

 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
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

 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 } });
	                        }
	                }
	        }
	}

}

Update an ErpObject

 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
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<string, object> { { "ID", 9 } });
	                                //Updating Rating and Price properties
	                                var updatedProduct = products.UpdatErpObject(product.GetKeys(), new Dictionary<string, object> { { "Rating", 9 }, { "Price", 1.99 } });
	                                Console.Write("New Price: {0}", updatedProduct["Price"]);
	                        }
	                }
	        }
	}

}

See also

Reference