All Projects → snickler → Efcore Fluentstoredprocedure

snickler / Efcore Fluentstoredprocedure

Licence: mit
EFCore Extension that allows a means to map a stored procedure to a class, fluently.

Programming Languages

csharp
926 projects

Projects that are alternatives of or similar to Efcore Fluentstoredprocedure

Binarypack
The fastest and most memory efficient binary serialization library for .NET Standard 2.1, powered by dynamic IL generation
Stars: ✭ 169 (+22.46%)
Mutual labels:  netstandard, dotnet-core
Akkatecture
a cqrs and event sourcing framework for dotnet core using akka.net
Stars: ✭ 414 (+200%)
Mutual labels:  netstandard, dotnet-core
Anclafs
ASP.NET Core Library and Framework Support
Stars: ✭ 192 (+39.13%)
Mutual labels:  netstandard, dotnet-core
Ether.network
https://github.com/Eastrall/Sylver
Stars: ✭ 147 (+6.52%)
Mutual labels:  netstandard, dotnet-core
Entityframeworkcore.dataencryption
A plugin for Microsoft.EntityFrameworkCore to add support of encrypted fields using built-in or custom encryption providers.
Stars: ✭ 88 (-36.23%)
Mutual labels:  netstandard, dotnet-core
WebGPU.NET
This repository contains low-level bindings for WebGPU used in WaveEngine.
Stars: ✭ 35 (-74.64%)
Mutual labels:  dotnet-core, netstandard
Gofer.net
Easy C# API for Distributed Background Tasks/Jobs for .NET Core.
Stars: ✭ 383 (+177.54%)
Mutual labels:  netstandard, dotnet-core
Metadata Extractor Dotnet
Extracts Exif, IPTC, XMP, ICC and other metadata from image, video and audio files
Stars: ✭ 518 (+275.36%)
Mutual labels:  netstandard, dotnet-core
Computesharp
A .NET 5 library to run C# code in parallel on the GPU through DX12 and dynamically generated HLSL compute shaders, with the goal of making GPU computing easy to use for all .NET developers! 🚀
Stars: ✭ 982 (+611.59%)
Mutual labels:  netstandard, dotnet-core
Steeltoe
Steeltoe .NET Core Components: CircuitBreaker, Configuration, Connectors, Discovery, Logging, Management, and Security
Stars: ✭ 612 (+343.48%)
Mutual labels:  netstandard, dotnet-core
Reinforced.tecture
Aspect-based architectural framework for .NET business applications involving some FP and CQRS principles.
Stars: ✭ 113 (-18.12%)
Mutual labels:  netstandard, dotnet-core
Raft.net
Implementation of RAFT distributed consensus algorithm among TCP Peers on .NET / .NETStandard / .NETCore / dotnet
Stars: ✭ 112 (-18.84%)
Mutual labels:  netstandard, dotnet-core
Colore
A powerful C# library for Razer Chroma's SDK
Stars: ✭ 121 (-12.32%)
Mutual labels:  netstandard, dotnet-core
Grandnode
Open source, headless, multi-tenant eCommerce platform built with .NET Core, MongoDB, AWS DocumentDB, Azure CosmosDB, Vue.js.
Stars: ✭ 1,768 (+1181.16%)
Mutual labels:  dotnet-core
Dotnetlabs
.NET Labs -- Show Me the Tips and Tricks and Code
Stars: ✭ 135 (-2.17%)
Mutual labels:  dotnet-core
Commandlineutils
Command line parsing and utilities for .NET
Stars: ✭ 1,782 (+1191.3%)
Mutual labels:  dotnet-core
Etl.net
Mass processing data with a complete ETL for .net developers
Stars: ✭ 129 (-6.52%)
Mutual labels:  dotnet-core
Azos
A to Z Sky Operating System / Microservice Chassis Framework
Stars: ✭ 137 (-0.72%)
Mutual labels:  netstandard
Wopihost
ASP.NET Core MVC implementation of the WOPI protocol. Enables integration with WOPI clients such as Office Online Server.
Stars: ✭ 132 (-4.35%)
Mutual labels:  dotnet-core
Oss.core
.net core下的领域开源电商网站,类库使用的标准库项目,集成微信和支付宝。 暂时还在开发阶段
Stars: ✭ 128 (-7.25%)
Mutual labels:  netstandard

Snickler.EFCore

Fluent Methods for mapping Stored Procedure results to objects in EntityFrameworkCore

NuGet

Usage

Executing A Stored Procedure

Add the using statement to pull in the extension method. E.g: using Snickler.EFCore

      var dbContext = GetDbContext();
      dbContext.LoadStoredProc("dbo.SomeSproc")
               .WithSqlParam("fooId", 1)              
               .ExecuteStoredProc((handler) =>
                {                  
                    var fooResults = handler.ReadToList<FooDto>();      
                    // do something with your results.
                });

Handling Multiple Result Sets

      var dbContext = GetDbContext();
      dbContext.LoadStoredProc("dbo.SomeSproc")
               .WithSqlParam("fooId", 1)              
               .ExecuteStoredProc((handler) =>
                {                  
                    var fooResults = handler.ReadToList<FooDto>();      
                    handler.NextResult();
                    var barResults = handler.ReadToList<BarDto>();
                    handler.NextResult();
                    var bazResults = handler.ReadToList<BazDto>()
                });

Handling Output Parameters

      DbParameter outputParam = null;
    
      var dbContext = GetDbContext();
      dbContext.LoadStoredProc("dbo.SomeSproc")
               .WithSqlParam("fooId", 1)  
               .WithSqlParam("myOutputParam", (dbParam) =>
               {                 
                 dbParam.Direction = System.Data.ParameterDirection.Output;
                 dbParam.DbType = System.Data.DbType.Int32;          
                 outputParam = dbParam;
               })
               .ExecuteStoredProc((handler) =>
                {                  
                    var fooResults = handler.ReadToList<FooDto>();      
                    handler.NextResult();
                    var barResults = handler.ReadToList<BarDto>();
                    handler.NextResult();
                    var bazResults = handler.ReadToList<BazDto>()
                });
                
                int outputParamValue = (int)outputParam?.Value;

Using output parameters without returning a result set

      DbParameter outputParam = null;

      var dbContext = GetDbContext();

      await dbContext.LoadStoredProc("dbo.SomeSproc")
            .WithSqlParam("InputParam1", 1)
            .WithSqlParam("myOutputParam", (dbParam) =>
            {
                  dbParam.Direction = System.Data.ParameterDirection.Output;
                  dbParam.DbType = System.Data.DbType.Int16;
                  outputParam = dbParam;
            })

            .ExecuteStoredNonQueryAsync();

      int outputParamValue = (short)outputParam.Value;

Using output parameters without returning a result set but also getting the number of rows affected

Make sure your stored procedure does not contain SET NOCOUNT ON.

      int numberOfRowsAffected = -1;

      DbParameter outputParam = null;

      var dbContext = GetDbContext();

      numberOfRowsAffected = await dbContext.LoadStoredProc("dbo.SomeSproc")
            .WithSqlParam("InputParam1", 1)
            .WithSqlParam("myOutputParam", (dbParam) =>
            {
                  dbParam.Direction = System.Data.ParameterDirection.Output;
                  dbParam.DbType = System.Data.DbType.Int16;
                  outputParam = dbParam;
            })

            .ExecuteStoredNonQueryAsync();

      int outputParamValue = (short)outputParam.Value;

Changing the execution timeout when waiting for a stored procedure to return

      DbParameter outputParam = null;

      var dbContext = GetDbContext();

      // change timeout from 30 seconds to 300 seconds (5 minutes)
      await dbContext.LoadStoredProc("dbo.SomeSproc", commandTimeout:300)
            .WithSqlParam("InputParam1", 1)
            .WithSqlParam("myOutputParam", (dbParam) =>
            {
                  dbParam.Direction = System.Data.ParameterDirection.Output;
                  dbParam.DbType = System.Data.DbType.Int16;
                  outputParam = dbParam;
            })

            .ExecuteStoredNonQueryAsync();

      int outputParamValue = (short)outputParam.Value;

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].