Using Cached Data
The provider also supports a third caching mode called offline mode, in which all statements are executed against the local cache database and not the real data source. This is enabled by setting the Offline option in the connection string.
With offline mode enabled, SELECT statements will always execute against the local cache database, regardless of whether you specify a table_name#Cache table or not. Modification of the cache is disabled in offline mode to prevent accidentally updating only the cached data. Executing a DELETE/UPDATE/INSERT statement while Offline is set will result in an exception.
Queries in offline mode do not have the same syntax limitations as queries run directly against the data source. In offline mode, any SQL query can be executed, including complex JOIN statements between multiple tables in the same database.
Select from the Cached Table
The command below will select from the local cache but not the live data source because Offline is set to true.
C#
using (NetSuiteConnection connection = new NetSuiteConnection("Account Id=XABC123456;Password=password;User=user;Role Id=3;Version=2013_1;Location=C:\\myfolder\\;Offline=true;Query Passthrough=true;Cache Location=C:\\cache.db;") {
String query = "SELECT * FROM Account WHERE acctName='Checking' ORDER BY AcctName ASC";
NetSuiteCommand cmd = new NetSuiteCommand(query, connection);
cmd.ExecuteReader();
}
VB.NET
Using conn As New NetSuiteConnection("Account Id=XABC123456;Password=password;User=user;Role Id=3;Version=2013_1;Location=C:\\myfolder\\;Offline=true;Query Passthrough=true;Cache Location=C:\\cache.db;")
Dim query As String = "SELECT * FROM Account WHERE acctName='Checking' ORDER BY AcctName ASC"
Dim cmd As NetSuiteCommand = New NetSuiteCommand(query, connection)
cmd.ExecuteReader()
End Using