Sharkable.AutoCrud.SqlSugar
0.5.6
dotnet add package Sharkable.AutoCrud.SqlSugar --version 0.5.6
NuGet\Install-Package Sharkable.AutoCrud.SqlSugar -Version 0.5.6
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="Sharkable.AutoCrud.SqlSugar" Version="0.5.6" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Sharkable.AutoCrud.SqlSugar" Version="0.5.6" />
<PackageReference Include="Sharkable.AutoCrud.SqlSugar" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Sharkable.AutoCrud.SqlSugar --version 0.5.6
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Sharkable.AutoCrud.SqlSugar, 0.5.6"
#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.
#:package Sharkable.AutoCrud.SqlSugar@0.5.6
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Sharkable.AutoCrud.SqlSugar&version=0.5.6
#tool nuget:?package=Sharkable.AutoCrud.SqlSugar&version=0.5.6
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Sharkable.AutoCrud.SqlSugar
Automatic CRUD API generation for Sharkable with SqlSugar ORM.
Install
dotnet add package Sharkable.AutoCrud.SqlSugar
Usage
Step 1: Configure DB
builder.Services.AddShark(opt =>
{
opt.ConfigureAutoCrud(s =>
{
s.DbType = DbType.Sqlite;
s.ConnectionString = "DataSource=app.db";
});
});
Step 2: Define entity + endpoint
[SugarTable("products")]
public class Product
{
[SugarColumn(IsPrimaryKey = true)]
public int Id { get; set; }
public string Name { get; set; } = "";
public decimal Price { get; set; }
}
public class ProductEndpoint : ISharkEndpoint, IAutoCrudEntity<Product>
{
// Empty — all 5 CRUD operations auto-generated
}
Auto-generated routes (api/product):
| Method | Route | Operation |
|---|---|---|
GET |
/ |
List all |
GET |
/{id} |
Get by ID |
POST |
/ |
Create |
PUT |
/{id} |
Update |
DELETE |
/{id} |
Delete |
Suppress Operations
public class ReadOnlyEndpoint : ISharkEndpoint, IAutoCrudEntity<Product>
{
CrudOperations IAutoCrudEntity<Product>.AllowedOperations =>
CrudOperations.List | CrudOperations.Get;
// POST/PUT/DELETE suppressed
}
Custom Override
Write your own route in AddRoutes — it takes precedence over auto-generated:
public class ProductEndpoint : ISharkEndpoint, IAutoCrudEntity<Product>
{
public void AddRoutes(IEndpointRouteBuilder app)
{
// Override the auto-generated GET list
app.MapGet("/", async (ISqlSugarClient db) =>
{
var list = await db.Queryable<Product>()
.Where(p => p.Price > 0)
.OrderBy(p => p.Name)
.ToListAsync();
return Results.Ok(list);
});
}
}
Health Check
SqlSugar database connectivity is automatically checked via /healthz (when EnableHealthChecks = true):
{
"checks": {
"SqlSugar": {
"status": "healthy",
"description": "SqlSugar connected in 3ms",
"data": { "latencyMs": 3, "dbType": "Sqlite" }
}
}
}
License
MIT
There are no supported framework assets in this package.
Learn more about Target Frameworks and .NET Standard.
-
- Sharkable (>= 0.5.6)
- SqlSugarCore (>= 5.1.4.215)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
CS1591 XML doc comments on all public API types and members (fix). CS1574 unresolved cref references (fix). Bump Sharkable dependency to 0.5.6.