![]() |
VOOZH | about |
This article illustrates using LINQ to access tables within the IBM Cloud Object Storage via the CData ADO.NET Data Provider for IBM Cloud Object Storage. To achieve this, we will use LINQ to Entity Framework, which facilitates the generation of connections and can be seamlessly employed with any CData ADO.NET Data Providers to access data through LINQ.
See the help documentation for a guide to setting up an EF 6 project to use the provider.
Enter your data source connection information.
If you do not already have Cloud Object Storage in your IBM Cloud account, follow the procedure below to install an instance of SQL Query in your account:
There are certain connection properties you need to set before you can connect. You can obtain these as follows:
To connect with IBM Cloud Object Storage, you need an API Key. You can obtain this as follows:
If you have multiple accounts, specify the CloudObjectStorageCRN explicitly. To find the appropriate value, you can:
You can now set the following to connect to data:
When you connect, the connector completes the OAuth process.
Below is a typical connection string:
ApiKey=myApiKey;CloudObjectStorageCRN=MyInstanceCRN;Region=myRegion;OAuthClientId=MyOAuthClientId;OAuthClientSecret=myOAuthClientSecret;
Using the entity you created, you can now perform select commands. For example:
IBMCloudObjectStorageEntities context = new IBMCloudObjectStorageEntities();
var objectsQuery = from objects in context.Objects
select objects;
foreach (var result in objectsQuery) {
Console.WriteLine("{0} {1} ", result.Id, result.Key);
}
See "LINQ and Entity Framework" chapter in the help documentation for example queries of the supported LINQ.
Download a free trial of the IBM Cloud Object Storage Data Provider to get started:
Download NowLearn more:
👁 IBM Cloud Object Storage IconRapidly create and deploy powerful .NET applications that integrate with IBM Cloud Object Storage.