The Gyrum.Data Database Access Layer is a .NET 3.5 module that abstracts away most of the specifics of the various SQL data sources comonly used today. This allows for a single code base to run on top of different data sources with no more than a configuration file change. For example, you can maintain a single business object layer that runs on a SQL Server database for in-house users, and runs on an Access database for remote, disconnected users.
As a quick introduction, consider the following code snippet:
string sql = "SELECT ProductId, Code, Description FROM Products WHERE Code = @Code@ ";
Command cmd = new Command(CommandType.Text, sql, new Parameter("Code", productCode));
using(Connection cn = DataAccess.Providers["CFO"].GetConnection())
using(GyrumDataReader dr = cn.ExecuteReader(cmd))
// populate object's values...
object.Id = dr.GetGuid("ProductId");
object.Code = dr.GetString("Code");
object.Description = dr.GetString("Description');
This code sets up the SQL statement, creates a Gyrum.Data.Command object, gets a Gyrum.Data.Connection object (based on a provider name), and finally gets a GyrumDataReader to read the data retrieved. Practically all of your SQL database access code can be reduced to something this simple. The benefits to using the Gyrum.Data module include:
- one code base can target multiple database types
- it's simple and easy to use
- it's free!