ReadOnly and Writable Entities
Great performance and simplified change tracking using ReadOnly and Writable entities in Umbraco Commerce.
Why have ReadOnly and Writable entities?
Converting a ReadOnly entity into a Writable entity
_uowProvider.Execute(uow =>
{
// Fetch the currency
var currency = _currencyService.GetCurrency(currencyId);
// Convert the currency into it's Writable form
var writableCurrency = currency.AsWritable(uow);
// Peform our write operation
writableCurrency.SetName("New Name");
// Persist the changes to the database
_currencyService.SaveCurrency(currency);
// Close our transaction
uow.Complete();
});
Last updated
Was this helpful?