Core Concepts > Basic Queries

Delete Statements

Using dbExpression, you can compose and execute direct deletes against the target database without first retrieving affected records.

In addition to Execute, Delete includes ExecuteAsync to asynchronously delete data.

The following query issues a delete to the Purchase table where Purchase.Id equals the literal value 9.

int idToDelete = 9;

int affected = db.Delete()
    .From(dbo.Product)
    .Where(dbo.Product.Id == idToDelete)
    .Execute();

Execution of a delete query returns the affected row count.

Previous
Update Statements

© 2024 dbExpression. All rights reserved.