AdditionalInfo entity
This section describes how to work with AdditionalInfo entity.
AdditionalInfo
entity is a dictionary with string key and object value, so the value can be a simple type or an object.
There are a few things to keep in mind regarding value data type:
- DateTimeOffset is recommended since it contains the time zone information. But if DateTime is used, make sure it is Coordinated Universal Time (UTC)
- Object: must implement
Litium.ComponentModel.IReadonly
- List: Because a list is not a simple type, it cannot be added directly.
There are 2 different ways to add additional information:
-
Using anonymous type or class
await cartContext.AddOrUpdateAdditionalInfoAsync(new
{
Name = "Value"
});
-
Using Dictionary<string, object>
await cartContext.AddOrUpdateAdditionalInfoAsync(new Dictionary<string, object>
{
{ "Name", "Value" }
});
The key/property will be added if it does not already exist in AdditionalInfo
; the other keys will be unaffected.
To update the existing key, we set the new value for the existing key.
await cartContext.AddOrUpdateAdditionalInfoAsync(new
{
Name = "new value"
});
To delete additional information, we set null for the existing key.
await cartContext.AddOrUpdateAdditionalInfoAsync(new
{
Name = (string)null
});
Order
The additional order information is added via the method AddOrUpdateAdditionalInfoAsync
of Litium.Sales.CartContext
var cartContext = _cartContextFactory.CreateAsync(createCartContextArgs)
await cartContext.AddOrUpdateAdditionalInfoAsync(new
{
Name = "Value"
});
Order row
The additional order row information is added via the method AddOrUpdateItemAsync
of Litium.Sales.CartContext
var cartContext = _cartContextFactory.CreateAsync(createCartContextArgs)
await cartContext.AddOrUpdateItemAsync(new AddOrUpdateCartItemArgs
{
ArticleNumber = "Article1",
AdditionalInfo = new
{
Name = "Value"
}
});