ADO.NET Provider for NoSQL Databases

ActiveX Data Objects (ADO).NET has been widely accepted as one of the many ways to connect to data sources. It is a set of object-oriented libraries in .NET designed to support a variety of data sources. It is named after the provider it supports, just like others, such as the SQL, Oracle and Borland data providers. ADO.NET provides a common methodology for almost all relational data sources available, which makes switching your database provider a manageable task and a real option.

Keeping these ADO.NET aspects in mind, NosDB is the only non-relational document database solution which also supports the ADO.NET dedicated database provider. This is made possible through NosDB’s powerful SQL querying capabilities. Moreover, since ADO.NET is extremely useful to  application developers for data migration, NosDB supports seamless integration of existing applications. Furthermore, with the addition of SQL JOINs in NosDB’s next release, ADO.NET integration will become a truly attractive feature for database migration and data queries.

ADO.NET Provider for NoSQL Database

In this short tutorial, I will demonstrate the use of ADO.NET with NosDB, with the help of sample code . But, before working on the actual code, there are a few changes required to the app.config files. The code below shows these changes:

In this sample configuration, note the name of the connection is set to NosDbConnection following the ADO.NET standard. In addition to this, the NosDB provider name, Alachisoft.NosDB.ADO.NETProvider, must be explicitly mentioned.  Moreover, do not forget to add the DbProviderFactories tag and the related configuration in your app.config files.

Once done with these configuration changes, you can  write some code for your application. A sample is written below for reference:

The code above demonstrates how to make use of the provider to read data from a NosDB database. Note that it closely follows the generally accepted data provider norms for these protocols. This makes migrating your applications an easy task. All you need to do is add the connection string, the Alachisoft namespace and change the configuration. What’s left is to change the SQL queries being called per the collections that you generated in NosDB and fetch data according the JSON schema that you are using. For this you would want to utilize the flexibility and fluidity of the JSON format.

For a more hands-on migration experience take a look at this Migrating Northwind Article.

In addition to facilitating database migration, the same NosDB ADO.NET integration allows you to bind your data to data grid views in either a Windows Form application or in ASP.NET Web Forms. I’ll cover that in a different blog post. But with this example, we reach the end of this short blog post. I hope it familiarized the reader with how NosDB uses ADO.NET standards to connect to data, and to simplify database migration – even from a relational database to a NoSQL database.

Leave a Reply

Your email address will not be published. Required fields are marked *