I'm trying to delete all the records from a table using this approach:
new Delete<Contact>().Execute();
This statement fails with a NullReferenceException
in BuildDeleteStatement
method at line:
sb.Append(query.FromTables[0].QualifiedName);
Because, although FromTables has one entry, it is set to null. I also tried this but it doesn't worked either:
var provider = ProviderFactory.GetProvider("MonitorData");
new Delete<Contact>(provider).Execute();
What am I doing wrong?
You can do this with the repo DeleteMany method:
SubSonicRepository<Contact> repo = new SubSonicRepository<Contact>(new YourDB());
repo.DeleteMany(contact => true);
The lambda I'm using is just to ensure all records are selected.