API suggestion: DeferCommand

83 views
Skip to first unread message

Johannes Gustafsson

unread,
Jan 16, 2012, 8:33:18 AM1/16/12
to rav...@googlegroups.com
Hi,

I have a scenario where I am using a regular document session where I want to delete a document that is not in the session. So I need to do this:

var session = store.OpenSession();
//do stuff
session.Advanced.DatabaseCommands.Delete(someOtherDocumentId);
session.SaveChanges(); // commit other changes

What would be nice is a way to defer the delete command so it will be called at SaveChanges() and get one less round trip to the DB:

var session = store.OpenSession();
//do stuff
session.Advanced.DatabaseCommands.DeferCommand(new DeleteCommandData() { ... });
session.SaveChanges(); // now, the actual delete command will be sent in the same round trip as everything else.

What do you think?

/Johannes

Oren Eini (Ayende Rahien)

unread,
Jan 16, 2012, 8:35:44 AM1/16/12
to rav...@googlegroups.com
It should be relatively easy to add this feature. You can do that by modifying how we handle PrepareForSaveChanges.
A pull request would be nice.

Johannes Gustafsson

unread,
Jan 16, 2012, 8:45:11 AM1/16/12
to rav...@googlegroups.com
Ok, I'll try!

2012/1/16 Oren Eini (Ayende Rahien) <aye...@ayende.com>

Johannes Gustafsson

unread,
Jan 17, 2012, 5:04:24 PM1/17/12
to rav...@googlegroups.com
Done:  https://github.com/ravendb/ravendb/pull/440 

2012/1/16 Johannes Gustafsson <johan...@gmail.com>

Oren Eini (Ayende Rahien)

unread,
Jan 18, 2012, 4:58:21 PM1/18/12
to rav...@googlegroups.com
Cool, did you send us a CLA?
Reply all
Reply to author
Forward
0 new messages