Mapping Classes
For each pair of an internal entity and an external entity that should be synchronized, you implement a mapping class, which defines the correspondence between the properties of the internal and external entities.
Base Class and Interfaces
You derive a mapping class from the PX.Commerce.Core.MappedEntity<ExternType, LocalType> base class, which implements the following interfaces:
- PX.Commerce.Core.IMappedEntity: Represents the mapping between the properties of the local and external objects
- PX.Commerce.Core.IMappedEntityExtern<ExternType>: Provides methods for the addition of an external entity to the mapping
- PX.Commerce.Core.IMappedEntityLocal<LocalType>: Provides a method for the addition of an internal entity to the mapping
The MappedEntity<ExternType, LocalType> class provides the default
implementation of these interfaces. The class also provides the default constructors from
which you can derive the constructors of the mapping classes. These constructors use as
input parameters a string
identifier of the mapped entities, which is
exactly two characters long, and a string
identifier of the connector,
which is defined in the ConnectorType property of the connector
class.
Example
An example of the implementation of a mapping class is shown in the following code.
using System;
using PX.Commerce.Core;
using PX.Commerce.Core.API;
namespace WooCommerceTest
{
public class MappedCustomer : MappedEntity<CustomerData, Customer>
{
public const string TYPE = BCEntitiesAttribute.Customer;
public MappedCustomer()
: base(WooCommerceConnector.TYPE, TYPE)
{ }
public MappedCustomer(Customer entity, Guid? id, DateTime? timestamp)
: base(WooCommerceConnector.TYPE, TYPE, entity, id, timestamp) { }
public MappedCustomer(CustomerData entity, string id, DateTime? timestamp)
: base(WooCommerceConnector.TYPE, TYPE, entity, id, id, timestamp) { }
}
}