Skip to content

rosebyte/AdoSession

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

33 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

ADO wrapper SQL database session

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages