views:

26

answers:

1

I've been reading a bit of Azure code lately and wonder why the examples I see on the Internet don't seem to take advantage of multiple operations per round trip. Is there a reason that people don't code their DataSource like this:

ForumDataSource.cs

   public void DeleteThread(params ForumThread[] itemToDelete)
    {
        foreach (var item in itemToDelete)
        {
            _ServiceContext.AttachTo(ForumDataServiceContext.ForumThreadTableName, item, "*");
            _ServiceContext.DeleteObject(item);
        }
        _ServiceContext.SaveChanges();
    }

That way multiple deletes can occur and the programming model is pretty clean.

A: 

Be sure to use SaveChangesOptions.Batch when calling SaveChanges... otherwise all the operations will be done as individual transactions. With that change, the above code should be fine, assuming all the items you're deleting are part of the same partition of the same table, and there are no more than one hundred of them (that's a limit of Windows Azure tables).

smarx