Asp – Working with SubSonic ‘deleted’ rows

asp.netsubsonic

When loading data with SubSonic (either using ActiveRecord or a collection), only records with IsDeleted set to false will load. How can I show those rows that have been deleted?

For example, deleting an Employee with:

Employee.Delete(1)

Now employee 1 is marked as deleted. Now I want the option to undo the delete and / or show a list of deleted employees, how can I do that? Either it will be undone if the user accidentally deleted the employee, or they want to go to a 'trash' list with previously deleted employees (i.e. only those with IsDeleted set to true).

Edit:
Using SubSonic 2.2

Best Answer

ActiveRecord doesn't have this built in. You'll need to set up additional queries for this. You didn't specify 2.2 or 3.0. This is 2.2 syntax.

public EmployeeCollection FetchAll(bool isDeleted)
{
    return new SubSonic.Select().From(Employee.Schema).Where(IsDeletedColumn).IsEqualTo(isDeleted).ExecuteAsCollection<EmployeeCollection>();
}

public EmployeeCollection GetTrashList()
{
    return FetchAll(true);
}
Related Topic