views:

245

answers:

2

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)

+3  A: 

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();
Adam
thanks, it's so obvious... :)
No problem, it's worth having a look at the help Paul linked to as well.
Adam
+1  A: 

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();
P a u l