Tago.Extensions.AspnetCore.IndexesAsApi.MsSql
6.0.0-preview-202501-11
dotnet add package Tago.Extensions.AspnetCore.IndexesAsApi.MsSql --version 6.0.0-preview-202501-11
NuGet\Install-Package Tago.Extensions.AspnetCore.IndexesAsApi.MsSql -Version 6.0.0-preview-202501-11
<PackageReference Include="Tago.Extensions.AspnetCore.IndexesAsApi.MsSql" Version="6.0.0-preview-202501-11" />
paket add Tago.Extensions.AspnetCore.IndexesAsApi.MsSql --version 6.0.0-preview-202501-11
#r "nuget: Tago.Extensions.AspnetCore.IndexesAsApi.MsSql, 6.0.0-preview-202501-11"
// Install Tago.Extensions.AspnetCore.IndexesAsApi.MsSql as a Cake Addin #addin nuget:?package=Tago.Extensions.AspnetCore.IndexesAsApi.MsSql&version=6.0.0-preview-202501-11&prerelease // Install Tago.Extensions.AspnetCore.IndexesAsApi.MsSql as a Cake Tool #tool nuget:?package=Tago.Extensions.AspnetCore.IndexesAsApi.MsSql&version=6.0.0-preview-202501-11&prerelease
Indexes-As-Api for MsSql
A dynamic MsSql API routes for ASP.NET Core
Welcome to the Dynamic MsSql API Routes package for ASP.NET Core! This innovative package aims to streamline the development process by automatically generating API routes based on MsSqlDB indexes. If you’re an ASP.NET Core developer working with MsSqlDB, this package will be a game-changer for you. It allows for the dynamic creation of routes without the need for manual configuration, saving you time and reducing the potential for errors.
- Dynamic Route Generation: Automatically creates API routes based on MsSqlDB indexes.
- Paging Support: Configurable paging options to handle large datasets efficiently.
- Flexible Configuration: Easily manage settings through
appsettings.json
.
Table of Contents
- Introduction
- Installation
- Usage
- Configuration
- Configuration Table(#Configuration Table)
- Conclusion
Introduction
In the fast-paced world of software development, efficiency and flexibility are paramount. As applications grow in complexity, managing API routes can become a daunting task, especially when dealing with a large number of collections and indexes. Traditional methods often require manual configuration, which can be both time-consuming and error-prone.
The Dynamic MsSql API Routes package addresses this challenge by leveraging the power of MsSqlDB indexes to auto-generate routes dynamically. This means that as your MsSqlDB schema evolves, your API routes are automatically updated, ensuring that your application remains in sync with your database structure.
Key Benefits
1. Automatic Route Generation: One of the standout features of this package is its ability to automatically generate API routes based on MsSqlDB indexes. This eliminates the need for manual route configuration, allowing to focus on more critical aspects of their application.
2. Enhanced Productivity: By automating the route generation process, this package significantly enhances productivity. With fewer manual configurations to manage, you can allocate more time to implementing features and improving the overall quality of the application.
3. Improved Consistency: Manual configuration is susceptible to human error, which can lead to inconsistencies and bugs. Automatic route generation ensures that routes are consistently defined based on the underlying MsSqlDB schema, reducing the risk of errors and improving the stability of your application.
4. Flexibility and Scalability: The package is designed to handle applications of varying sizes and complexities. Whether you're working on a small project or a large-scale enterprise application, Dynamic MsSql API Routes can easily scale to meet your needs. It supports multiple MsSqlDB collections and indexes, providing a flexible solution for dynamic API routing.
5. Simplified Maintenance: As your application grows and evolves, maintaining API routes can become a cumbersome task. With dynamic route generation, updates to your MsSqlDB schema are automatically reflected in your API routes, simplifying maintenance and reducing the overhead associated with manual updates.
6. Paging Support: Managing large datasets is a common challenge in modern applications. The package includes robust paging support, allowing to easily handle and paginate large collections of data. This ensures that your API remains performant and responsive, even when dealing with extensive datasets.
Installation
To install the Dynamic MsSql API Routes package, use the following command:
dotnet add package Tago.Extensions.AspnetCore.IndexesAsApi.MsSql
Usage
public static async Task Main(string[] args)
{
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddAuthorization();
MsSqlSettings MsSqlSettings = new MsSqlSettings();
builder.Configuration.GetSection("MsSql").Bind(MsSqlSettings);
builder.Services.AddMsSqlIndexesEndpoints(MsSqlSettings)
//.WithPersistance<IndexesPersistance>();
;
var app = builder.Build();
await app.UseMsSqlIndexesEndpointsAsync(cfg => {
//cfg.RoutesPrefix = "v1";
});
app.UseHttpsRedirection();
app.UseAuthorization();
app.Run();
}
Configuration
To configure the Dynamic MsSql API Routes package, add the following section to your appsettings.json
file:
"MsSql": {
//"CamelCaseModelProperties": false,
//"RequireAuthorization": false,
//"Swagger": {
// "TitleTemplate": "{database}-{collection}"
//},
"IsPagingEnabled": true,
"Paging": {
"DefaultItemsPerPage": 100,
"UsePagedResultModel": true,
"PagedResultHeaders": {
"TotalItemsHeader": "X-Total-Items",
"PageNumberHeader": "X-Page-Number",
"PageSizeHeader": "X-Page-Size"
}
},
"ErrorMessages": {
"UnIndexedQueryFilter": "Your search criteria isn't using any of the indexed fields"
},
"AutoGenerate": [
{
//"CamelCaseModelProperties": false,
//"Swagger": {
// "TitleTemplate": "{database}-{collection}"
//},
"ConnectionString": "Server=msSqlHost;Database=Northwind;User Id=test;password=test;",
"Database": "Northwind",
"Collections": [
"Customers",
"Suppliers"
],
"IsPagingEnabled": true,
"Paging": {
"IsPagingRequired": true,
"DefaultItemsPerPage": 100,
"UsePagedResultModel": false,
"PagedResultHeaders": {
"TotalItemsHeader": "X-Total-Items",
"PageNumberHeader": "X-Page-Number",
"PageSizeHeader": "X-Page-Size"
}
}
},
{
"ConnectionString": "Server=msSqlHost;Database=Northwind;User Id=test;password=test;",
"Database": "Northwind",
"Collections": [
"Employees"
],
"Paging": {
"IsPagingRequired": true
}
}
]
}
Configuration Table
Below is a table explaining each key in the configuration:
Key | Description |
---|---|
MsSql.RequireAuthorization |
Enables or disables authorization globally (default: true) |
MsSql.IsPagingEnabled |
Enables or disables paging for the entire configuration. |
Paging.DefaultItemsPerPage |
Sets the default number of items per page when paging is enabled. |
Paging.UsePagedResultModel |
Specifies whether to use a paged result model for responses. |
Paging.PagedResultHeaders |
Defines custom headers for paging information in the response. |
PagedResultHeaders.TotalItemsHeader |
Custom header name for the total number of items. |
PagedResultHeaders.PageNumberHeader |
Custom header name for the current page number. |
PagedResultHeaders.PageSizeHeader |
Custom header name for the page size. |
AutoGenerate.ConnectionString |
MsSqlDB connection string for the collection(s). |
AutoGenerate.Database |
Name of the MsSqlDB database. |
AutoGenerate.Collections |
List of collections in the database to generate routes for. |
AutoGenerate.RequireAuthorization |
Enables or disables authorization for the specific collection configuration. |
AutoGenerate.IsPagingEnabled |
Enables or disables paging for the specific collection configuration. |
AutoGenerate.Paging.IsPagingRequired |
Specifies whether paging is required for the specific collection configuration. |
AutoGenerate.Paging.DefaultItemsPerPage |
Sets the default number of items per page for the specific collection. |
AutoGenerate.Paging.UsePagedResultModel |
Specifies whether to use a paged result model for the specific collection. |
AutoGenerate.Paging.PagedResultHeaders |
Defines custom headers for paging information for the specific collection. |
Conclusion
In summary, the Dynamic MsSql API Routes package is an essential tool for ASP.NET Core working with MsSqlDB. By automating the route generation process, it enhances productivity, ensures consistency, and simplifies maintenance. This package can help you build scalable, efficient, and reliable applications with ease.
Embrace the future of dynamic API routing and elevate your development workflow with the Dynamic MsSql API Routes package for ASP.NET Core!
Please review the provided documentation and let me know if you would like any changes or additions.
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. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. |
-
net6.0
- System.Data.SqlClient (>= 4.8.6)
- Tago.Extensions.AspnetCore.IndexesAsApi.Abstractions (>= 6.0.0-preview-202501-11)
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 |
---|---|---|
6.0.0-preview-202501-11 | 35 | 2/19/2025 |