Ucommerce
  • Ucommerce Next Gen
    • Getting Started
      • Prerequisites
      • Licensing
      • Ucommerce Templates
      • Headless Template
      • MVC Template
    • Headless
      • Postman Collection
      • Headless API Authentication
        • Token endpoint - Authorization Header
        • Authorization Scopes
        • Refreshing the Access Token
      • Reference
        • Cart
        • Cart / Order Line Items
        • Shipment
        • Billing
        • Promotion Codes
        • Price Groups
        • Payment Methods
        • Countries
        • Shipping Methods
        • Catalogs
        • Cart Custom Properties
        • Line Item Custom Properties
        • Orders
        • Views for Cart modifying operations
      • Custom Headless APIs
      • Error Handling
      • Pagination
      • Deprecation
    • Backoffice Authentication
      • Microsoft Entra ID Example
      • Auth0 Authentication Example
    • Definitions
      • What is a Definition
    • Search and indexing
      • Configuration
      • Indexing
        • Index Definitions
        • Facets
        • Indexing Prices
        • Suggestions
        • Custom Data
      • Searching
    • Payment Providers
      • Stripe Provider Integration
      • Implementing a custom payment provider
    • Data Import
    • Miscellaneous
      • Media
      • Price Group Inheritance
      • Price Group Criteria
      • Soft Deletion Of Entities
      • Logging
      • OpenTelemetry
    • Extensions
      • Extending Pipelines
        • Order Processing Pipelines
        • Checkout Pipelines
      • Changing Service Behavior
        • Images
        • Content
      • Custom Headless APIs
      • Extend the Backoffice
        • Custom UI Components
      • Custom Editor UI
      • Custom Promotion Criteria
      • Custom Price Group Criteria
    • How-To
      • Migrate from Classic
        • Common database issues
      • Entities from code
        • Bootstrapping data on startup
        • Product Definitions & Fields
      • Discover pipelines and their tasks
      • Executing a pipeline
    • Integrations
      • Umbraco Media Delivery API
      • App Slices
        • Product Picker
  • Release Notes
  • Contact Us
Powered by GitBook
On this page
  • Permanently deleting an entity
  • Querying entities
  • List of soft deletable entities

Was this helpful?

  1. Ucommerce Next Gen
  2. Miscellaneous

Soft Deletion Of Entities

When deleting an entity in Ucommerce using

_dbContext.Remove(entity)
_dbContext.SavechangesAsync(cancellationToken)

or by using one of our APIs to remove an entity, EF Core deletion will be intercepted, and the entity will be checked for soft deletion. If the entity is soft deletable, the deleted flag will be set to true; otherwise, the deletion will go through to the database.

When an entity is soft deleted, its Deleted property will be set to true.

Permanently deleting an entity

It is possible to permanently delete soft deletable entities from the database. This can be done by calling ExecuteDelete or ExecuteDeleteAsync on the DbSet you want to delete from.

await _dbContext.Set<PriceGroup>()
    .Where(x => objectsToDelete.Select(p => p.Guid)
        .Contains(x.Guid))
    .ExecuteDeleteAsync(cancellationToken);

Remember to carefully filter your query if you wish to do this, as it circumvents all safety measures besides the ones directly built into the database.

Querying entities

When an entity is soft deleted, it will still be returned from direct queries to a DbContext. They can be filtered out based on the Deleted property.

await _dbContext.Set<PriceGroup>()
    .Where(x => !x.Deleted)
    .FirstOrDefaultAsync(x => x.Guid == guid, token)

List of soft deletable entities

The following entities are soft deleted by the system:

  • Campaign

  • Promotion

  • Category

  • Country

  • Currency

  • DataType

  • DataTypeEnum

  • Definition

  • DefinitionField

  • DefinitionType

  • EmailProfile

  • EmailType

  • OrderNumberSerie

  • PaymentMethod

  • PriceGroup

  • Catalog

  • Store

  • ProductDefinition

  • ProductDefinitionField

  • ShippingMethod

PreviousPrice Group CriteriaNextLogging

Last updated 11 months ago

Was this helpful?