使用SubSonic(使用ActiveRecord或集合)加载数据时,仅加载IsDeleted设置为false的记录.如何显示已删除的行?
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)现在,员工1被标记为已删除.现在,我想选择撤消删除和/或显示已删除员工的列表,我该怎么做?如果用户不小心删除了员工,或者他们想转到以前删除过的员工(即仅将 IsDeleted 设置为true的员工)进入废纸'"列表,则该操作将被撤消.
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).
使用SubSonic 2.2
Using SubSonic 2.2
推荐答案ActiveRecord没有内置此功能.您需要为此设置其他查询.您未指定2.2或3.0.这是2.2语法.
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); }更多推荐
使用SubSonic的“已删除"行
发布评论