SQLProcedureDAO 2.3.0
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package SQLProcedureDAO --version 2.3.0
NuGet\Install-Package SQLProcedureDAO -Version 2.3.0
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="SQLProcedureDAO" Version="2.3.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add SQLProcedureDAO --version 2.3.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: SQLProcedureDAO, 2.3.0"
#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 SQLProcedureDAO as a Cake Addin #addin nuget:?package=SQLProcedureDAO&version=2.3.0 // Install SQLProcedureDAO as a Cake Tool #tool nuget:?package=SQLProcedureDAO&version=2.3.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
SQLProcedureDAO
SQL Data access object to execute SQL Stored Procedures.
Note : Support User Defined Tables
Installation
Use the NuGet Package Manager to install SQLProcedureDAO.
PM> Install-Package SQLProcedureDAO
Usage
1 - Create a class extends DAOContext
public class ProductDAODbContext: DAOContext
{
public ProductDAODbContext() : base("ConnectionString")
{
}
}
2 - Create an object for ProductDAODbContext
ProductDAODbContext daoContext = new ProductDAODbContext();
- Create a ProductModel
// product model
public class ProductModel {
public int Id {get; set;}
public string ProductName {get; set;}
public decimal Price{get; set;}
}
3 - Execute Insert/Update procedure
- First parameter ⇒ Procedure name
- Second parameter ⇒ Argument names as string array
- Third parameter ⇒ Values as object array
Argument array and values array order should match
int res = daoContext.ExecuteStoredProcedure("InsertProduct",
new string[]{"ProductName", "Price"},
new object[]{"Rice", 54.2});
4- Execute Select procedure by retrieving only first value of first row
- Return value as type parameter
int res = daoContext.ExecuteStoredProcedure<int>("GetSumOfProduct",
new string[]{"ProductId"},
new object[]{1});
//without parameters
bool isNewOrderArrived = daoContext.ExecuteStoredProcedure<bool>("IsNewOrderArrived");
//type parameter as ProductModel, (Get first row only)
ProductModel productModel = daoContext.ExecuteStoredProcedure<ProductModel>("GetAllProducts");
//type parameter as List<ProductModel>
List<ProductModel> productModel = daoContext.ExecuteStoredProcedureAsList<ProductModel>("GetAllProducts");
4- Execute Procedure by User Defined Table (UDT)
List<ProductModel> productList = new List<ProductModel>()
{
new ProductModel{ProductName = "Cashew nut", Price = 450},
new ProductModel{ProductName = "Chilly Powder", Price = 40},
};
//specify UDT parameter name inside 3rd parameter as string[], should incluede in parameter names array
//return rows affected
int res = program.ExecuteStoredProcedureWithUDT(
procedureName: "InsertProducts",
parameterNames: new string[] { "CreatedAt", "IsActive", "Item" },
udtParameterNames: new string[] { "Item" },
values: new object[] { DateTime.Now, 1, productList });
/* return parameter as first column value from first row(If insert procedure end query is select statement)
or you can use custom models as return according to your procedure select statement */
int id = program.ExecuteStoredProcedureWithUDT<int>(
procedureName: "InsertProductASUDT",
parameterNames: new string[] { "CreatedAt", "IsActive", "Item" },
udtParameterNames: new string[] { "Item" },
values: new object[] { DateTime.Now, 1, productList });
License
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.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.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
- Improve performance