This project is read-only.

Clear all?

Oct 30, 2013 at 1:46 AM
Is there a simpler way to clear all instances of an object type other than iterating over all instances and deleting them one by one? Something along the lines of "DELETE FROM Foo" in SQL.
Nov 1, 2013 at 8:24 AM
Hello,
it depends from what you would like to delete in db. You could create simple wrapper per type, which will allow you on going through foreach and remove all items. There is no more efficient way to do that. because instances of the same type are not stored sequentially.

If you want to remove all instances of all types, just recreate db ;)
Nov 1, 2013 at 3:02 PM
Edited Nov 1, 2013 at 3:03 PM
So by this you mean something like:
public class Table<T>
{
    public List<T> Items;
}
And then for every object type Foo, I should store it in Table<Foo>.Items. Then I can call Remove(Table<Foo>), or perhaps Table<Foo>.Items.Clear(). Are changes to Items above incremental, ie. if I add two items, it doesn't re-save the whole collection? Querying can't be too efficient on this structure.
Nov 6, 2013 at 6:31 AM
It's up to you, how you would like to implement it. It could be implemented through Object wrapper, or just enumerator which will handle foreach actions for you.

Regards,
Jacek