Encapsulating ADO.NET Core Components - A C# Class Library - Online Free Computer Tutorials.

'Software Development, Games Development, Mobile Development, iOS Development, Android Development, Window Phone Development. Dot Net, Window Services,WCF Services, Web Services, MVC, MySQL, SQL Server and Oracle Tutorials, Articles and their Resources

Tuesday, June 12, 2012

Encapsulating ADO.NET Core Components - A C# Class Library

Introduction  

ADO.NET provides a lot of classes for accessing or manipulating data in the database. The use of these classes sometimes becomes repetitive. Imagine you have 5 different methods that perform a retrieval operation. Each method will most likely contain the following procedures:   

Create and open a connection object (System.Data.SqlClient.SqlConnection or System.Data.OracleClient.OracleConnection)   
Create a command object (System.Data.SqlClient.SqlCommand or System.Data.OracleClient.OracleCommand)   
Create and iterate through a data reader object to get the records from the database (System.Data.SqlClient.SqlDataReader or System.Data.OracleClient.OracleDataReader)  
With the class library I created, all these repetitive codes are taken care of. At the heart of the class library is the OpenEm.QLite.Database class that hides the initialization of the core components of ADO.NET while also exposing them as an event argument property or as a callback parameter so that developers can still access their properties.   

Background        

Many of you might already be using an Object-relational Mapping (ORM) tool in your projects. I do too. However, the main reason why I created this class library is because recently, I faced a situation wherein I needed something that is straightforward, gives me full control in writing the SQL statements, and does not hide the mapping between retrieved database records and CLR objects.  

Read More...


I guess you came to this post by searching similar kind of issues in any of the search engine and hope that this resolved your problem. If you find this tips useful, just drop a line below and share the link to others and who knows they might find it useful too. 

Stay tuned to my blogtwitter or facebook to read more articles, tutorials, news, tips & tricks on various technology fields. Also Subscribe to our Newsletter with your Email ID to keep you updated on latest posts. We will send newsletter to your registered email address. We will not share your email address to anybody as we respect privacy.


No comments:

Post a Comment