Skip to content

fargeartech/simple-data-access-handler

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 

Repository files navigation

A Simple Data Access Handler for ADO.NET

A simple data access layer to access different type of database. A simple wrapper will handle will support normal connection including transaction.

Supported Database

SQL Server MySQL SQLite

Updated Soon

Oracle , ODBC and OLEDB

How To Use

Always wrap the DBWrapper by utilizing using statement to ensure all connection has been dispose properly to prevent memory leak.

  using (var dal = new DBWrapper("DBConnection"))

DBConnection is your webconfig connection name where this library will automatically find connectionstring and provider name.

 <connectionStrings>
    <add name="DBConnection" connectionString="Data Source=localhost;Initial Catalog=demo;Integrated Security=True" providerName="System.Data.SqlClient" />
    <add name="DBSQLite" connectionString="Data Source=mydb.db;Version=3;" providerName="System.Data.Sqlite" />
  </connectionStrings>

you will have the flexibility to use Stor Proc or Direct Query which require your needs.

using stor proc

  using (var dal = new DBWrapper("DBConnection"))
            {
                try
                {
                    var user = new User
                    {
                        FirstName = "First",
                        LastName = "Last",
                        Dob = DateTime.Now.AddDays(-3000),
                        IsActive = true
                    };

                    int count = dal.GetScalarValue("MY_STOR_PROC_NAME", CommandType.StoredProcedure);
                    Console.WriteLine("current total " + count.ToString());
           -- skip for brevity

using direct query

  using (var dal = new DBWrapper("DBConnection"))
            {
                try
                {
                    var user = new User
                    {
                        FirstName = "First",
                        LastName = "Last",
                        Dob = DateTime.Now.AddDays(-3000),
                        IsActive = true
                    };

                    int count = dal.GetScalarValue("select count(*) from table", CommandType.Text);
                    Console.WriteLine("current total " + count.ToString());
           -- skip for brevity

for full example you can refer C# Example and for VB.NET VB.NET Example

Thank you and happy Coding 💗 from Malaysia

About

A simple data access layer to access different type of database.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published