ADOWrappers 1.0.1
dotnet add package ADOWrappers --version 1.0.1
NuGet\Install-Package ADOWrappers -Version 1.0.1
<PackageReference Include="ADOWrappers" Version="1.0.1" />
paket add ADOWrappers --version 1.0.1
#r "nuget: ADOWrappers, 1.0.1"
// 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:
- Connection String
- Store Procedure Name or Sql Query
- Command Type. (CommandType.Text || CommandType.StoreProcedure) depending on what you're pass for param 2
- 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 | Versions 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. |
-
net6.0
- FastMember (>= 1.5.0)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 8.0.1)
- System.Data.SqlClient (>= 4.8.6)
-
net7.0
- FastMember (>= 1.5.0)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 8.0.0)
- System.Data.SqlClient (>= 4.8.6)
-
net8.0
- FastMember (>= 1.5.0)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 8.0.0)
- System.Data.SqlClient (>= 4.8.6)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Add Notes and Structure with Sample to Repository