Cmdlets for OData

Build 20.0.7587

CacheProvider Parameter (Connect-OData Cmdlet)

The name of the provider to be used to cache data.

Syntax

Connect-OData -CacheProvider string

Remarks

You can cache to any database for which you have an ADO.NET provider . The caching database is determined based on the CacheProvider and CacheConnection properties.

The following sections show connection examples and address other requirements for several popular database drivers. Refer to CacheConnection for more information on typical connection properties.

Loading the Caching Database's Driver

The CacheProvider property specifies the name of the DbProviderFactory used to cache data. You can find the provider factories available to you in your machine.config.

SQLite

The cmdlet simplifies SQLite configuration; in most caching scenarios, you need to specify only the CacheLocation.

CacheLocation=C:\\Users\\Public\\cache.db;User=myuseraccount;Password=mypassword;URL=http://myserver/myOrgRoot;
The following example uses the Sync-OData cmdlet to cache the Lead table or incrementally update the cached copy:
Connect-OData -User 'MyUser' -Password 'MyPassword' -URL 'http://myserver/myOrgRoot' -CacheLocation 'C:\Users\Public\cache.db' | Sync-OData -Table "Lead"
You can persist the results of your queries while online for later use while offline: Set the AutoCache parameter in the Connect-OData cmdlet and invoke the Select-OData cmdlet, as shown in the following example:
Connect-OData -User 'MyUser' -Password 'MyPassword' -URL 'http://myserver/myOrgRoot' -CacheLocation 'C:\Users\Public\cache.db' -AutoCache | Select-OData -Table "Lead" -Where "FirstName <> 'Bartholomew'"

MySQL

To cache to MySQL, you can use the included CData ADO.NET Provider for MySQL:

Cache Provider=System.Data.CData.MySQL;Cache Connection='Server=localhost;Port=3306;Database=cache;User=root;Password=123456';User=myUser;Password=myPassword;Security Token=myToken;
The CData ADO.NET Provider for MySQL is included in the CData Cmdlets PowerShell Module for OData installation. The following example uses the Sync-OData cmdlet to cache the Lead table or incrementally update the cached copy:
Connect-OData -User 'MyUser' -Password 'MyPassword' -URL 'http://myserver/myOrgRoot' -CacheProvider 'System.Data.CData.MySQL' -CacheConnection 'Server=localhost;Port=3306;Database=cache;User=root;Password=123456' | Sync-OData -Table "Lead"
You can persist the results of your queries while online for later use while offline: Set the AutoCache parameter in the Connect-OData cmdlet and invoke the Select-OData cmdlet:
Connect-OData -User 'MyUser' -Password 'MyPassword' -URL 'http://myserver/myOrgRoot' -CacheProvider 'System.Data.CData.MySQL' -CacheConnection 'Server=localhost;Port=3306;Database=cache;User=root;Password=123456' -AutoCache | Select-OData -Table "Lead" 

SQL Server

You can use the Microsoft .NET Framework Provider for SQL Server, included in the .NET Framework, to cache to SQL Server:

Cache Provider=System.Data.SqlClient;Cache Connection="Server=MyMACHINE\MyInstance;Database=SQLCACHE;User ID=root;Password=admin";User=myuseraccount;Password=mypassword;URL=http://myserver/myOrgRoot;
The following example uses the Sync-OData cmdlet to cache the Lead table or incrementally update the cached copy:
OData Connect-OData -User 'MyUser' -Password 'MyPassword' -URL 'http://myserver/myOrgRoot' -CacheProvider 'System.Data.SqlClient' -CacheConnection 'Server=MyMACHINE\MyInstance;Database=SQLCACHE;User ID=root;Password=admin' | Sync-OData -Table "Lead"
You can persist the results of your queries while online for later use while offline: Set the AutoCache parameter in the Connect-OData cmdlet and invoke the Select-OData cmdlet:
Connect-OData -User 'MyUser' -Password 'MyPassword' -URL 'http://myserver/myOrgRoot' -CacheProvider 'System.Data.SqlClient' -CacheConnection 'Server=MyMACHINE\MyInstance;Database=SQLCACHE;User ID=root;Password=admin' -AutoCache | Select-OData -Table "Lead" 

Oracle

To cache to Oracle, you can use the Oracle Data Provider for .NET, as shown in the following example:

Cache Provider=Oracle.DataAccess.Client;Cache Connection='User Id=scott;Password=tiger;Data Source=ORCL';User=myuseraccount;Password=mypassword;URL=http://myserver/myOrgRoot;

The Oracle Data Provider for .NET also requires the Oracle Database Client. When you download the Oracle Database Client, ensure that the bitness matches the the bitness of your machine. When you install select either the Runtime or Administrator installation type;, the Instant Client is not sufficient. The following commands use the Sync-OData cmdlet to cache the Lead or incrementally update the cached copy:

Connect-OData Connect-OData -User 'MyUser' -Password 'MyPassword' -URL 'http://myserver/myOrgRoot' -CacheProvider 'Oracle.DataAccess.Client' -CacheConnection "User Id=scott;Password=tiger;Data Source=ORCL" | Sync-OData -Table "Lead"
You can persist the results of your queries while online for later use while offline: Set the AutoCache parameter in the Connect-OData cmdlet and invoke the Select-OData cmdlet, as shown in the following example:
Connect-OData -User 'MyUser' -Password 'MyPassword' -URL 'http://myserver/myOrgRoot' -CacheProvider 'Oracle.DataAccess.Client' -CacheConnection "User Id=scott;Password=tiger;Data Source=ORCL" -AutoCache | Select-OData -Table "Lead"

PostgreSQL

You can use the Npgsql ADO.NET provider to cache to PostgreSQL, as shown in the following example:

CacheProvider=Npgsql;CacheConnection="Host=myserver;Username=mylogin;Password=mypass;Database=mydatabase";User=myuseraccount;Password=mypassword;URL=http://myserver/myOrgRoot;
You can use the Npgsql ADO.NET provider to cache to PostgreSQL. The following commands use the Sync-OData cmdlet to cache the Lead table or incrementally update the cached copy:
Connect-OData -User 'MyUser' -Password 'MyPassword' -URL 'http://myserver/myOrgRoot' -CacheProvider 'Npgsql' -CacheConnection "Host=myserver;Username=mylogin;Password=mypass;Database=mydatabase" | Sync-OData -Table "Lead"
You can persist the results of your queries while online for later use while offline: Set the AutoCache parameter in the Connect-OData cmdlet and invoke the Select-OData cmdlet:
Connect-OData -User 'MyUser' -Password 'MyPassword' -URL 'http://myserver/myOrgRoot' -CacheProvider 'Npgsql' -CacheConnection "Host=myserver;Username=mylogin;Password=mypass;Database=mydatabase" -AutoCache | Select-OData -Table "Lead"

Copyright (c) 2020 CData Software, Inc. - All rights reserved.
Build 20.0.7587