DeltaWare.SDK.EntityFrameworkCore
6.0.0.1
DeltaWare.SDK.Extensions.EntityFrameworkCore 7.0.0.1
Additional DetailsThis package is no longer supported as it has been split and renamed to DeltaWare.SDK.Extensions.EntityFrameworkCore and DeltaWare.SDK.Extensions.EntityFrameworkCore.SqlServer.
See the version list below for details.
dotnet add package DeltaWare.SDK.EntityFrameworkCore --version 6.0.0.1
NuGet\Install-Package DeltaWare.SDK.EntityFrameworkCore -Version 6.0.0.1
<PackageReference Include="DeltaWare.SDK.EntityFrameworkCore" Version="6.0.0.1" />
paket add DeltaWare.SDK.EntityFrameworkCore --version 6.0.0.1
#r "nuget: DeltaWare.SDK.EntityFrameworkCore, 6.0.0.1"
// Install DeltaWare.SDK.EntityFrameworkCore as a Cake Addin #addin nuget:?package=DeltaWare.SDK.EntityFrameworkCore&version=6.0.0.1 // Install DeltaWare.SDK.EntityFrameworkCore as a Cake Tool #tool nuget:?package=DeltaWare.SDK.EntityFrameworkCore&version=6.0.0.1
SQL Stored Procedures
This middle-ware is intended to provide a simple and straightforward way of executing stored procedures. The current implementation handles creation of the SQL Command, opening and closing a connection, disposing of instances and mapping the return type.
Supported Return Type
- Scalar
ExecuteScalarAsync<int>();
- Types
ExecuteAsync<MyType>();
- Lists
ExecuteAsync<List<MyType>>();
Executing an SQL Stored Procedure.
NOTE: SQL Stored Procedures can only be executed when using UseSqlServer, otherwise a MethodAccessException will be thrown.
There are presently three ways of assigned parameters to an SQL stored procedure.
- Anonymous type mapping
- Direct type mapping
NOTE:
Direct type mapping supports property selection.
- SQL Parameters Building
Anonymous Code Mapping
public Task<ReturnType> RunSomethingAsnc(string myParameterA, int myParamaterB, DateTime myParamaterB)
return _myDbContext
.RunSqlStoredProcedure("{MyStoredProcedure}")
.WithParameters(new
{
myParameterA,
MYPARAMETERB = myParameterB,
MyPARAMETERc = myParameterC
})
.ExecuteAsync<ReturnType>();
}
In the above example the following code will map to.
EXEC [dbo].[MyStoredProcedure]
@myParameterA = 'Some text',
@MYPARAMETERB = '42',
@MyPARAMETERc = '01-01-2012'
Direct Type Mapping
public class MyType
{
public string Title { get; set; }
public DateTime endDate { get; set;}
}
public Task<List<ReturnType>> DoSomethingElseAsync(MyType parameterA)
{
return _myDbContext
.RunSqlStoredProcedure("{MyOtherStoredProcedure}")
.WithParameters(parameterA)
.ExecuteAsync<List<ReturnType>>();
}
In the above example the following code will map to.
EXEC [dbo].[MyOtherStoredProcedure]
@Title = 'Dr',
@endDate = '01-01-2012'
Using Property Selection
public Task<List<ReturnType>> DoSomethingElseAsync(MyType parameterA)
{
return _myDbContext
.RunSqlStoredProcedure("{MyOtherStoredProcedure}")
.WithParameters(parameterA, p => new { p.Title })
.ExecuteAsync<List<ReturnType>>();
}
In the above example the following code will map to.
EXEC [dbo].[MyOtherStoredProcedure]
@Title = 'Dr'
SQL Parameter Builder
public Task<ReturnType> RunAnotherThingAsync(string myParameterA, int myParamaterB, DateTime myParamaterB)
return _myDbContext
.RunSqlStoredProcedure("{MyStoredProcedure}")
.WithParameters(b =>
{
b.AddParameter("@myParameterA", SqlDbType.VarChar, myParameterA);
b.AddParameter("@MYPARAMETERB", SqlDbType.Int, myParameterB);
b.AddParameter("@MyPARAMETERc", SqlDbType.Date, myParameterC);
})
.ExecuteAsync<ReturnType>();
}
In the above example the following code will map to.
EXEC [dbo].[MyStoredProcedure]
@myParameterA = 'Some text',
@MYPARAMETERB = '42',
@MyPARAMETERc = '01-01-2012'
Stored Procedure Options
Set Command Timeout
.RunSqlStoredProcedure("{MyStoredProcedure}", o =>
{
o.Timeout = 1472;
})
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 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. |
-
net6.0
- DeltaWare.SDK.Core (>= 6.0.0.1)
- Microsoft.EntityFrameworkCore (>= 6.0.2)
- Microsoft.EntityFrameworkCore.Relational (>= 6.0.2)
- Microsoft.EntityFrameworkCore.SqlServer (>= 6.0.2)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.