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
2009-05-18 16:06:53
thanks, it's so obvious... :)
2009-05-18 16:27:53
No problem, it's worth having a look at the help Paul linked to as well.
Adam
2009-05-18 16:33:40
+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
2009-05-18 16:12:29