Michal
Michal

Reputation:

Delete all records from a table

How can I delete all records from a table using SubSonic? The Delete method has three overloads, but each one expects some parameters. And how can I delete records using a query (e.g. delete all records where column1 > 100)

Upvotes: 0

Views: 846

Answers (2)

P a u l
P a u l

Reputation: 7921

Help is located at http://subsonicproject.com/docs/Main_Page and many examples for this are in the tests included with the source.

int records = new Delete().From(Product.Schema)
    .Where("UnitPrice")
    .IsGreaterThan(42.00)
    .Execute();

// Delete all rows.
int records = new Delete().From(Product.Schema).Execute();

Upvotes: 1

Adam Cooper
Adam Cooper

Reputation: 8687

The following will delete all rows from the TempTable which have an Id of greater than 56:

new Delete().From(TempTable.Schema)
  .Where(TempTable.Columns.Id).IsGreaterThan(56)
  .Execute();

Upvotes: 3

Related Questions