Entity
An Entity object is of type PSObject and represents a specific entity from the ERP system, or its nested complex type data.
The $entity object is created automatically based on the type definition from the ERP system’s $metadata:
All properties defined in the ERP are included with their corresponding names and values.
Simple property values are returned using their corresponding .NET types, while complex type- and navigation properties are returned as nested Entity instances.
Complex Types do not have Keys
Instances of complex types do not provide any _Keys.
According to the OData specification, only entity types define keys. Complex types are therefore actually not true “entities”, even though they share many of the same characteristics.
Syntax
$entity._Keys
Following read-only properties are always available:
Type |
Name |
Description |
|---|---|---|
PSObject |
_Keys |
Contains only the Key properties that uniquely identify an entity. |
PSObject |
_Properties |
All other properties (except keys) and their values. |
Examples
Simple properties of an ERP entity:
Connect-Erp -Service 'http://services.odata.org/V4/Northwind/Northwind.svc/'
$entity = Get-ERPObject -EntitySet 'Customers' -Keys @{ 'CustomerID' = 'ANTON' }
<#
CustomerID : ANTON
CompanyName : Antonio Moreno Taquería
ContactName : Antonio Moreno
ContactTitle : Owner
Address : Mataderos 2312
City : México D.F.
Region :
Postalcode : 05023
Country : Mexico
Phone : (5) 555-3932
Fax :
#>
Accessing _Keys and _Properties of an ERP entity (including nested objects):
Connect-Erp -Service 'https://services.odata.org/V3/(S(xnnohcch2jddbn1z1ytpfni2))/OData/OData.svc/'
$supplier = Get-ERPObject -EntitySet 'Suppliers' -Keys @{ 'ID' = 0 } -Expand 'Products'
$supplier._Keys
<#
ID : 0
#>
$supplier._Properties
<#
Name : Exotic Liquids
Concurrency : 0
Location : @{Latitude=-122.107711791992; Longitude=47.6472206115723}
Address : @{ <- complex type property
Street : NE 228th
City : Sammamish
State : WA
ZipCode : 98074
Country : USA
_Keys :
_Properties : @{Street=NE 228th; City=Sammamish; State=WA; ZipCode=98074; Country=USA}
}
Products : @{ <-expanded navigation property collection
ID : 1
Name : Milk
Description : Low fat milk
ReleaseDate : 1995-10-01T00:00:00
DiscontinuedDate :
Rating : 3
Price : 3.5
_Keys : @{ID=1}
_Properties : @{Name=Milk; Description=Low fat milk; ReleaseDate=1995-10-01T00:00:00; DiscontinuedDate=; Rating=3; Price=3.5}
},
@{
ID : 2
Name : Vint soda
Description : Americana Variety - Mix of 6 flavors
ReleaseDate : 2000-10-01T00:00:00
DiscontinuedDate :
Rating : 3
Price : 20.9
_Keys : @{ID=2}
_Properties : @{Name=Vint soda; Description=Americana Variety - Mix of 6 flavors; ReleaseDate=2000-10-01T00:00:00; DiscontinuedDate=; Rating=3; Price=20.9}
}
#>