LiteX.DbHelper.PostgreSql 2.0.0

This is a tiny library helps write less code, to execute queries and stored procedures against PostgreSql as like any normal CLR method.
     It is just written for the purpose to bring a new level of ease to the developers who deal with ADO.NET for data access.
    
     LiteXDbHelper is simple and tiny yet powerful and very high-performance library to working with ADO.NET.

Install-Package LiteX.DbHelper.PostgreSql -Version 2.0.0
dotnet add package LiteX.DbHelper.PostgreSql --version 2.0.0
<PackageReference Include="LiteX.DbHelper.PostgreSql" Version="2.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add LiteX.DbHelper.PostgreSql --version 2.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

Features

Basic features
  • ExecuteNonQuery
  • ExecuteScalar
  • GetDataTable
  • GetDataSet
  • ExecuteReder
  • CreateParameters (for each providers)
Advanced features
  • ExecuteScalar<>
  • GetSingle<T>
  • GetList<T>
  • GetArray<T>
  • GetDictionary<TKey, TValue>

Instantiate the DBHelper:

...
// just use the connection string name
IDBHelper dbHelper = new NpgsqlHelper("MyCN");
// use different provider class based on your database.

Basic ADO.NET methods:

// Create parameters
var paramResultOut = DbHelper.CreateOutParameter("@Result", SqlDbType.NVarChar, 100);
var paramIsActive = DbHelper.CreateParameter("@IsActive", isActive);
var paramId = DbHelper.CreateParameter("@Id", id);

  
// ExecuteNonQuery
// Stored procedure
var count = _dbHelper.ExecuteNonQuery("DeleteCountry", paramIsActive, paramResultOut);
// OR
// Raw sql commnad
var count = _dbHelper.ExecuteNonQuery("DELETE FROM [dbo].[Country] WHERE Id = @Id", CommandType.Text, paramIsActive);


// ExecuteScalar - returning a object type scalar value 
var name = _dbHelper.ExecuteScalar("SELECT Name FROM COUNTRY");


// DataReader
// Stored procedure
var dataReader = _dbHelper.ExecuteReder("GetCountries", paramIsActive, paramResultOut);
// OR
// Raw sql commnad
var dataReader = _dbHelper.ExecuteReder("SELECT * FROM Country WHERE IsActive = @IsActive", CommandType.Text, paramIsActive);


// DataTable
// Stored procedure
var dataTable = _dbHelper.GetDataTable("GetCountries", paramIsActive, paramResultOut);
// OR
// Raw sql commnad
var dataTable = _dbHelper.GetDataTable("SELECT * FROM Country WHERE IsActive = @IsActive", CommandType.Text, paramIsActive);


// DataSet
// Stored procedure
var dataSet = _dbHelper.GetDataSet("GetCountriesAndStates", paramIsActive, paramResultOut);

Features

Basic features
  • ExecuteNonQuery
  • ExecuteScalar
  • GetDataTable
  • GetDataSet
  • ExecuteReder
  • CreateParameters (for each providers)
Advanced features
  • ExecuteScalar<>
  • GetSingle<T>
  • GetList<T>
  • GetArray<T>
  • GetDictionary<TKey, TValue>

Instantiate the DBHelper:

...
// just use the connection string name
IDBHelper dbHelper = new NpgsqlHelper("MyCN");
// use different provider class based on your database.

Basic ADO.NET methods:

// Create parameters
var paramResultOut = DbHelper.CreateOutParameter("@Result", SqlDbType.NVarChar, 100);
var paramIsActive = DbHelper.CreateParameter("@IsActive", isActive);
var paramId = DbHelper.CreateParameter("@Id", id);

  
// ExecuteNonQuery
// Stored procedure
var count = _dbHelper.ExecuteNonQuery("DeleteCountry", paramIsActive, paramResultOut);
// OR
// Raw sql commnad
var count = _dbHelper.ExecuteNonQuery("DELETE FROM [dbo].[Country] WHERE Id = @Id", CommandType.Text, paramIsActive);


// ExecuteScalar - returning a object type scalar value 
var name = _dbHelper.ExecuteScalar("SELECT Name FROM COUNTRY");


// DataReader
// Stored procedure
var dataReader = _dbHelper.ExecuteReder("GetCountries", paramIsActive, paramResultOut);
// OR
// Raw sql commnad
var dataReader = _dbHelper.ExecuteReder("SELECT * FROM Country WHERE IsActive = @IsActive", CommandType.Text, paramIsActive);


// DataTable
// Stored procedure
var dataTable = _dbHelper.GetDataTable("GetCountries", paramIsActive, paramResultOut);
// OR
// Raw sql commnad
var dataTable = _dbHelper.GetDataTable("SELECT * FROM Country WHERE IsActive = @IsActive", CommandType.Text, paramIsActive);


// DataSet
// Stored procedure
var dataSet = _dbHelper.GetDataSet("GetCountriesAndStates", paramIsActive, paramResultOut);

Release Notes

Advanced features (Strongly type result) - ExecuteScalar, GetSingle, GetList, GetArray, GetDictionary
     DBConvert methods, DataReader, DataTable and DataTable extensions
     1.0.0 - Basic featured - ExecuteNonQuery, ExecuteScalar, GetDataTable, GetDataSet, ExecuteReder, CreateParameter
     Coming soon - Async methods support
     Comimg soon - OUT parameter support in stored procedure
     Coming soon - Ping (useful in health check and load balancing)
     Coming soon - Pagination at DB server side
     Coming soon - Batch execution

This package is not used by any popular GitHub repositories.

Version History

Version Downloads Last updated
2.0.0 38 9/19/2019
1.0.0 313 6/25/2019