Skip to content

Latest commit

 

History

History
65 lines (48 loc) · 1.96 KB

README.md

File metadata and controls

65 lines (48 loc) · 1.96 KB

DbSession.Core NuGet

ADO wrapper SQL database session

DbSession

Facade class publishing all the interesting methods. Its' constructed with connection string of type "Data Source=...".

DbSession.Select

DbSession.Execute

DbSession.GetScalar

DbSession.ExecuteOnTransaction

DbSession.Commit

DbSession.Rollback

DbSession.CloseConnection

IValueSet

Fetched row data wrapper used to get rid of DataReader.

DbParameter

SQL parameter wrapper used to isolate concrete provider classes. It expects name, C# type and value

var parameter = new DbParameter("Id", typeof(int), 5)
  // there is other way of creating parameter instance
var otherParameter = new DbParameter<int>("Id", 5)

They are commonly aggregated to sets - any parameter set must contain parameter for each placeholder (e.g. parameter with name "Something" if there is placeholder "@Something" in a SQL script).

var parameterSet = new DbParameterSet
{
  new SqlParameter<string>("Name", "Max"),
  new SqlParameter<string>("Surname", "Example"),
  new SqlParameter<int>("Age", 24)
}

In case of executing batches there are IEnumerable to be inserted. The thing is that the same SQL script will be ran once with each parameter set in this enumeration (i.e. with different parameter values each time).

var parameterSetBatch = new DbParameterSet[] 
{ 
  new DbParameterSet
  {
    new SqlParameter<string>("Name", "Max"), 
    new SqlParameter<string>("Surname", "Example"), 
    new SqlParameter<int>("Age", 24)
  },
  new DbParameterSet
  {
    new SqlParameter<string>("Name", "Max"), 
    new SqlParameter<string>("Surname", "Example"), 
    new SqlParameter<int>("Age", 24)
  }
}

DbSession.Sqlite NuGet