BctSP 1.0.2

There is a newer version of this package available.
See the version list below for details.
dotnet add package BctSP --version 1.0.2                
NuGet\Install-Package BctSP -Version 1.0.2                
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="BctSP" Version="1.0.2" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add BctSP --version 1.0.2                
#r "nuget: BctSP, 1.0.2"                
#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 BctSP as a Cake Addin
#addin nuget:?package=BctSP&version=1.0.2

// Install BctSP as a Cake Tool
#tool nuget:?package=BctSP&version=1.0.2                

BctSp

This project has been developed with the .NET Standart 2.1 and allows you to call stored procedure from the database by simply creating only interface and methods signature without needing any concrete class to call any stored procedure. It can work async and sync. It provides stored procedure support for MsSQL and MySQL, function support for PostgreSQL.

Installation

BctSP is available in Nuget. Anybody can install it via Nuget Package Manager.

https://www.nuget.org/packages/BctSP

Usage

  • Add BctSp service to your application builder in Program.cs and set BctSpConnectionStringOrConfigurationPath and DatabaseType for database connection which can be MsSQL or MySQL or PostgreSQL.
builder.Services.AddBctSp((x) =>
{
    // x.BctSpConnectionStringOrConfigurationPath = "Server=...";
    x.BctSpConnectionStringOrConfigurationPath = "Databases:ConnectionString";
    x.DatabaseType = BctSpDatabaseType.PostgreSql;
});
  • Create a request that inherits from the BctSpBaseRequest. Generic argument of the BctSpBaseRequest should be the response type of the request that inherits BctSpBaseResponse.
    public class GetProductsByPriceRequest : BctSpBaseRequest<GetProductsByPriceResponse>
    {
        public GetProductsByPriceRequest(string bctSpName) : base(bctSpName)
        {
        }

        public decimal ProductPrice { get; set; }

    }
  • Create a response that inherits from the BctSpBaseResponse.
	public class GetProductsByPriceResponse : BctSpBaseResponse
	{

		public string ProductName { get; set; }

		public decimal ProductPrice { get; set; }

		public string ProductDescription { get; set; }
	}
  • Create an interface which implements IBctSp and has method signatures.
	public interface ISampleSP : IBctSp
	{
	 
		List<GetProductsByPriceResponse> GetProductsByPrice(GetProductsByPriceRequest request);
	 
		Task<List<GetProductsByPriceResponse>> GetProductsByPriceAsync(GetProductsByPriceRequest request);

	}
  • Get the interface with Dependency injection pattern.
public class WeatherForecastController
{
    private readonly ISampleSP _sampleSp;

    public WeatherForecastController(ISampleSP sampleSp)
    {
        _sampleSp = sampleSp;
    }
  • Sample Usage
        public List<GetProductsByPriceResponse> GetProductsByPrice()
        {
            var response = _sampleSp.GetProductsByPrice(new GetProductsByPriceRequest("yourSPname") { ProductPrice = 100 });

            return response;
        }

        public async Task<List<GetProductsByPriceResponse>> GetProductsByPriceAsync()
        {
            var response = await _sampleSp.GetProductsByPriceAsync(new GetProductsByPriceRequest("yourSPname") { ProductPrice = 100 });

            return response;
        }
  • Customized Usage -- the database configuration can be overridden and customized for each request if it is needed.
    public List<GetProductsByPriceResponse> GetProductsByPrice()
    {
        var response = _sampleSp.GetProductsByPrice(
            new GetProductsByPriceRequest("yourSPname",
                "CustomDatabases:ConnectionString",
                BctSpDatabaseType.MsSql) { ProductPrice = 100 });

        // var response = _sampleSp.GetProductsByPrice(
        //     new GetProductsByPriceRequest("yourSPname",
        //         "Server=...",
        //         BctSpDatabaseType.MsSql) { ProductPrice = 100 });

        return response;
    }
    
    public async Task<List<GetProductsByPriceResponse>> GetProductsByPriceAsync()
    {
        var response = await _sampleSp.GetProductsByPriceAsync(
            new GetProductsByPriceRequest("yourSPname",
                "CustomDatabases:ConnectionString",
                BctSpDatabaseType.MsSql) { ProductPrice = 100 });

        // var response = await _sampleSp.GetProductsByPriceAsync(
        //     new GetProductsByPriceRequest("yourSPname",
        //         "Server=...",
        //         BctSpDatabaseType.MsSql) { ProductPrice = 100 });

        return response;
    }

Contact Me:   - LinkedIn   -   Mail


Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  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 was computed.  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 Core netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos 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
2.0.0 183 8/16/2023
1.0.3 151 5/22/2023
1.0.2 170 5/20/2023
1.0.1 162 5/20/2023
1.0.0 156 5/20/2023