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
await _uowProvider.ExecuteAsync(async (uow) =>
{
// Fetch the currency
var currency = await _currencyService.GetCurrencyAsync(currencyId);
// Convert the currency into it's Writable form
var writableCurrency = await currency.AsWritableAsync(uow);
// Peform our write operation
await writableCurrency.SetNameAsync("New Name");
// Persist the changes to the database
await _currencyService.SaveCurrencyAsync(currency);
// Close our transaction
uow.Complete();
});
Last updated
Was this helpful?