Voyager.DBConnection 4.1.5

dotnet add package Voyager.DBConnection --version 4.1.5                
NuGet\Install-Package Voyager.DBConnection -Version 4.1.5                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Voyager.DBConnection" Version="4.1.5" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Voyager.DBConnection --version 4.1.5                
#r "nuget: Voyager.DBConnection, 4.1.5"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Voyager.DBConnection as a Cake Addin
#addin nuget:?package=Voyager.DBConnection&version=4.1.5

// Install Voyager.DBConnection as a Cake Tool
#tool nuget:?package=Voyager.DBConnection&version=4.1.5                


Library providing connection to SQL database using DbProviderFactory.

How to use it

Implement interface Voyager.DBConnection.Interfaces.ICommandFactory:

	public interface ICommandFactory : IReadOutParameters
		DbCommand ConstructDbCommand(Database db);

Example code is like:

	internal class SetPilotiDoPowiadomieniaFactory : Voyager.DBConnection.Interfaces.ICommandFactory
		private readonly int idBusMapRNo;
		private readonly DateTime busMapDate;
		private readonly string idAkwizytor;
		private readonly string raport;

		public SetPilotiDoPowiadomieniaFactory(int idBusMapRNo, DateTime busMapDate, string idAkwizytor, string raport)
			this.idBusMapRNo = idBusMapRNo;
			this.busMapDate = busMapDate;
			this.idAkwizytor = idAkwizytor;
			this.raport = raport;
		public DbCommand ConstructDbCommand(Database db)
			var cmd = db.GetStoredProcCommand("BusMap.p_SetPilotiDoPowiadomienia");
			db.AddInParameter(cmd, "IdBusMapRNo", DbType.Int32, this.idBusMapRNo);
			db.AddInParameter(cmd, "BusMapDate", DbType.Date, this.busMapDate);
			db.AddInParameter(cmd, "IdAkwizytor", DbType.AnsiString, this.idAkwizytor);
			db.AddInParameter(cmd, "Raport", DbType.AnsiString, this.raport);

			return cmd;

		public void ReadOutParameters(Database db, DbCommand command)

Using your DbProviderFactory create your type of database object Voyager.DBConnection.Database and Voyager.DBConnection.Connection. On the connection object call ExecuteNonQuery the command factory:

			SetPilotiDoPowiadomieniaFactory factory = new SetPilotiDoPowiadomieniaFactory(tagItem.IdBusMapRNp, tagItem.BusMapDate, tagItem.IdAkwizytor, tagItem.Raport);

For reading data implement IGetConsumer interface:

internal class RegionalSaleCommand : Voyager.DBConnection.Interfaces.ICommandFactory, IGetConsumer<SaleItem[]>
		private RaportRequest request;

		public RegionalSaleCommand(RaportRequest request)
			this.request = request;
		public DbCommand ConstructDbCommand(Database db)
			var cmd = db.GetStoredProcCommand("[dbo].[TestSaleReport]");
			db.AddInParameter(cmd, "IdAkwizytorRowNo", System.Data.DbType.Int32, request.IdAkwizytorRowNo);
			db.AddInParameter(cmd, "IdPrzewoznikRowNo", System.Data.DbType.Int32, request.IdPrzewoznikRowNo);
			db.AddInParameter(cmd, "DataPocz", System.Data.DbType.DateTime, request.DateFrom);
			db.AddInParameter(cmd, "DataKon", System.Data.DbType.DateTime, request.DateTo);

			return cmd;

		public SaleItem[] GetResults(IDataReader dataReader)
			List<SaleItem> lista = new List<SaleItem>();

			while (dataReader.Read())
				int col = 0;
				SaleItem item = new SaleItem();
				item.GidRezerwacji = dataReader.GetString(col++);
				item.GIDL = dataReader.GetString(col++);

				DateTime data = dataReader.GetDateTime(col++);

				var ts = dataReader.GetValue(col++);

				TimeSpan czas = ts.ToString().CastTimeSpan();

				item.DataSprzedazy = data.AddTicks(czas.Ticks);
				item.IdWaluta = dataReader.GetString(col++);
				item.IdWalutaBazowa = DBSafeCast.CastEmptyString(dataReader.GetValue(col++));
				item.KursDniaBaz = (Double)DBSafeCast.Cast<Decimal>(dataReader.GetValue(col++), 1);
				item.NettoZ = DBSafeCast.Cast<Decimal>(dataReader.GetValue(col++), 0);
				item.WalutaZcennika = dataReader.GetBoolean(col++);


			return lista.ToArray();

		public void ReadOutParameters(Database db, DbCommand command)


Next, call the GetReader method:

		public class RaportDB : Voyager.Raport.DBEntity.Store.Raport
		private readonly Connection connection;

		public RaportDB(Voyager.DBConnection.Connection connection)
			this.connection = connection;
		public RaportResponse GetRaport(RaportRequest request)
			RegionalSaleCommand raport = new RegionalSaleCommand(request);
			return new RaportResponse()
				Items = connection.GetReader(raport, raport)


There is an extension used to log operations. Voyager.DBConnection.Logging. After installing on the connection obcjet is needed to call extension:

namespace Voyager.DBConnection
	public static class ConnectionLogger
		public static void AddLogger(this Connection connection, ILogger logger)
			connection.AddFeature(new LogFeature(logger, connection));

MS Sql provider

For using MS SQL Provider is prepared the Nuget Voyager.DBConnection.MySql. There is provided implementation of the connection object:

namespace Voyager.DBConnection.MsSql
	public class SqlConnection : Connection
		public SqlConnection(string sqlConnectionString) : base(new SqlDatabase(sqlConnectionString), new ExceptionFactory())

✍️ Authors

  • @andrzejswistowski - Idea & work. Please let me know if you find out an error or suggestions.


🎉 Acknowledgements

  • Przemysław Wróbel - for the icon.
Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Framework net48 is compatible.  net481 was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETFramework 4.8

    • No dependencies.
  • net6.0

    • No dependencies.
  • net8.0

    • No dependencies.

NuGet packages (2)

Showing the top 2 NuGet packages that depend on Voyager.DBConnection:

Package Downloads

Implementation MS Sql extension for Voyager.DBConnection


Logging extension for Voyager.DBConnection

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
4.1.5 265 3/5/2024
4.1.3 79 3/5/2024
4.1.2 297 12/5/2023
4.1.1 120 12/5/2023
4.1.0 151 11/22/2023
4.0.3 115 11/13/2023
4.0.0 129 10/31/2023
3.0.1 177 5/5/2023
3.0.0 118 5/5/2023