Some things are more expensive than others when using the Office Accounting SDK, here is a few tips I have found along the way:

If doing bulk inserts or updates you will probably get better performance if you disable refreshing from the database...

We have three useful properties for this:


ISmallBusinessInstanceV2.DisableAsyncRefreshSetting this to false will disable your DataViews from being refreshed with changes from other instances (~other clients). This is normally done asynchronously.


ISmallBusinessInstanceV2.SuppressRefresh     Setting this to false will disable your DataViews from being refreshed with changes from your own changes. This is normally done synchronously after you save.


IBaseMasterEntityV2.DisableReloadAfterSave   Setting this to true on your entity will disable a reload of the entity from the database after a save, this is useful is you just want to save and forget.


Your code will look something like this:


    instance.SuppressRefresh = true;



    Do your inserts and updates





        instance.SuppressRefresh = false;



If you are creating documents with inventory items, keep in mind that changing inventory back in time will make Office Accounting recalculate the inventory on later transactions. Now, I understand that if you have to do it you have to do it, but if you keep it in mind you may be able to reorganize your code to limit the recalculates (try to insert in a chronological order).


Be aware that when you call the DataView property on a IBaseMasterEntity you actually fetch all the rows of that type from the database, so only do that when necessary. One way to limit the number of calls to the property could be to cache the DataView in a variable so you don’t have to call the property again and again.


In many situations you can avoid reading the whole DataView to access the rows that you are interested in. Often you are really just interested in a few primary keys that will allow you to access the actual objects. One way to do this can be to access the EntityViews directly by selecting from the database. Generally we recommend going through the SDK however optimizing by reading from the database can be necessary, just keep in mind that the views potentially could change in future versions of Office Accounting.


Another useful cache in some applications: the ISmallBusinessInstance; if you have an application that often recreates the instance you may see a performance improvement by simply caching the instance and reusing it.


Naturally none of these tips can just be applied to code without thinking about scenarios, and more importantly; always remember to measure your performance to ensure you are actually improving and not just complicating things…