Skip to content

Latest commit

 

History

History
43 lines (38 loc) · 1.51 KB

README.md

File metadata and controls

43 lines (38 loc) · 1.51 KB

MyORM

ADO.Net and SQL server

  1. Create new database connection object using
using (var dbConnection = ConnectionFactory.CreateConnection(connectionString))
{
    // database operations
}

OR

using (var dbConnection = ConnectionFactory.CreateConnection())
{
    // database operations
}
  1. where connectionString is string object which has value of connectionstring for database, or it will take default connectionstring from web config. Name of the default connectionstring must be "DefaultConnection".

Methods for text Query

  • dbConnection.ExecuteSingle(); // with/Without Mapper
  • dbConnection.ExecuteList(); // with/Without Mapper
  • dbConnection.ExecuteNonQuery();
  • dbConnection.ExecuteScalar();
  • dbConnection.ExecuteNonQueryWithScope(); // with return parameter

Methods for Stored Procedure

  • dbConnection.ExecuteSingleProc(); // with/Without Mapper
  • dbConnection.ExecuteListProc(); // with/Without Mapper
  • dbConnection.ExecuteNonQueryProc();
  • dbConnection.ExecuteScalarProc();
  • dbConnection.ExecuteNonQueryProcWithReturn() // with return parameter, Name of the return parameter must be "ReturnValue"

Methods for transaction

  • dbConnection.BeginTransaction();
  • dbConnection.CommitTransaction();
  • dbConnection.RollbackTransaction();

Other Methods

  • dbConnection.GetConnectionString();
  • dbConnection.GetOutParameters();
  • dbConnection.Dispose(); // dbConnection object will be automatically disposed as it inherits IDisposable.