- Scaffolds your StoredProcedures and Models to C# Files
- Easy managed by CLI
- Skallable and expandable
- no rigid dependencies
SpocR pulls the DB scheme over a given ConnectionString into spocr.json
The spocr.json is configurable (e.g. You can choose which scheme to build or ignore)
SpocR generates the DataContext-Folder with all required C# Code for your .net core Application (App, API or Services)
SpocR is highly scalable. You can build it as Library, Extension or Default (both together as single Project)
You can use UserDefinedTableFunctions or single Values as Parameters. The result of your StoredProcedures will be mapped as Model or List SpocR also is supporting pure JSON-String Result from StoredProcedure without building any Models.
./DataContext
./DataContext/Models/[schema]/[StoredProcedureName].cs
./DataContext/StoredProcedures/[schema]/[EntityName]Extensions.cs
./DataContext/TableTypes/[schema]/[TableTypeName].cs
./DataContext/AppDbContext.cs
./DataContext/AppDbContextExtensions.cs
./DataContext/SqlDataReaderExtensions.cs
./DataContext/SqlParameterExtensions.cs
- Register
IAppDbContext
in Startup.cs
services.AddAppDbContext();
- Inject IAppDbContext into your business logic, e.g. your managers or services.
private readonly IAppDbContext _context;
constructor MyManager(IAppDbContext context)
{
_context = context;
}
- Call a stored procedure method
public Task<List<UserList>> ListAsync(CancellationToken cancellationToken = default)
{
return _dbContext.UserListAsync(User.Id, cancellationToken);
}
- EntityName (required): Name of base SQL-Table
- Action (required): Create | Update | Delete | (Merge, Upsert) | Find | List
- Suffix: WithChildren | (custom suffix)
- [ResultId] INT, [RecordId] INT
- Database: SQL-Server Version 2012
- Web-API: ASP.NET Core 2
- Microsoft.Data.SqlClient
- Microsoft.Extensions.Configuration
- Install .NET Core 2.1
> dotnet tool install --global SpocR
- Clone and Download Repository:
git clone https://github.com/nuetzliches/spocr.git
- if installed:
dotnet tool uninstall -g spocr
- install local build:
cd src
dotnet pack --output ./ --configuration Release
dotnet tool install -g spocr --add-source ./
spocr create
spocr rebuild
spocr pull
spocr build
spocr remove
- Default (Default): SpocR will create a standalone project with all dependencies
- Lib: SpocR will create a spocr-library to include it into other projects, with AppDbContext and dependencies
- Extension: SpocR will create a extendable project, without AppDbContext and dependencies, to inlude an existing spocr-lib. You have to configure the namespace (Project.Role.LibNamespace) to resolve the spocr-lib
- Under construction ... https://github.com/nuetzliches/nuts
- http://roslynquoter.azurewebsites.net/
- https://natemcmaster.com/blog/2018/05/12/dotnet-global-tools/
- SQL Server cannot determine the nullable prop on computed columns for sure. So if you want to a proper model, you need to ISNULL({....} ,0) your computed column