ADOWrappers 1.0.1

dotnet add package ADOWrappers --version 1.0.1
NuGet\Install-Package ADOWrappers -Version 1.0.1
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="ADOWrappers" Version="1.0.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add ADOWrappers --version 1.0.1
#r "nuget: ADOWrappers, 1.0.1"
#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 ADOWrappers as a Cake Addin
#addin nuget:?package=ADOWrappers&version=1.0.1

// Install ADOWrappers as a Cake Tool
#tool nuget:?package=ADOWrappers&version=1.0.1

ADO Wrappers

Description

This nuget package contain many util, extensions and etc to help developer speed up their coding process.

SQL Data Reader & SQL DataTable

This is a nuget package which will allow you to simpily map a Sql Data Reader to any class. It is a generic class that will return a list of <T> where T: is a class. Simpily register the package in your startup.

builder.Services.UseSqlDataReaderMapper();

Or you can directly instantiate the generic classes as they are not an abstract class.

To use in any of your class, inject the interface in your constructor.

public class MyClass
{
	private readonly IGenericSqlDataReader _genericSqlReader;
	public MyClass(IGenericSqlDataReader genericSqlReader)
	{
		_genericSqlReader = genericSqlReader;
	}

	public async List<MyOjbect> GetListOfObject(string param1)
	{
		//Parameter are optional
		SqlParameter[] parameters = new SqlParameter[]
		{
			new SqlParameter("@ParamName", SqlDbType.VarChar, 12) { Value = param1 },
			// Add other parameters as needed
		};
		return await _genericSqlReader.ExecuteReaderAsync<MyOjbect>("connectionString", "myStoreProcedure", CommandType.StoredProcedure, parameters );
	}

}


Paramaters:

  1. Connection String
  2. Store Procedure Name or Sql Query
  3. Command Type. (CommandType.Text || CommandType.StoreProcedure) depending on what you're pass for param 2
  4. This is an optional if your query or Store Procedure require Parameter's.

Notes

There is also an synchronous method if you don't need an async method.

In addition, there is extension to map your "SqlDataReader" object to a class(No dependancy Registration Required). For Example:

using (var dataReader = sqlCommand.ExecuteReader(CommandBehavior.Default))
{
	if (dataReader.HasRows)
	{
		while (dataReader.Read())
		{
			var newObject = new T();
			dataReader.MapDataToObject(newObject);
			newListObject.Add(newObject);
		}
	}
}

You can also used the mapping extension for your "DataTable".

using (var dataTable = new SqlDataAdapter(sqlCommand))
{
	DataTable dt = new();
	dataTable.Fill(dt);
	if (dt.Rows.Count > 0)
	{
		newListObject = dt.ConvertDataTable<T>();
	}
}

This package uses the package FastMember

Free to use

Built for .net 8

Created By Sunil Anthony

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 is compatible.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.1 127 3/21/2024
1.0.0 215 2/23/2024

Add Notes and Structure with Sample to Repository