DotNetBrightener.WebApi.GenericCRUD 2025.0.9-preview-487

This is a prerelease version of DotNetBrightener.WebApi.GenericCRUD.
There is a newer prerelease version of this package available.
See the version list below for details.
dotnet add package DotNetBrightener.WebApi.GenericCRUD --version 2025.0.9-preview-487
                    
NuGet\Install-Package DotNetBrightener.WebApi.GenericCRUD -Version 2025.0.9-preview-487
                    
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="DotNetBrightener.WebApi.GenericCRUD" Version="2025.0.9-preview-487" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="DotNetBrightener.WebApi.GenericCRUD" Version="2025.0.9-preview-487" />
                    
Directory.Packages.props
<PackageReference Include="DotNetBrightener.WebApi.GenericCRUD" />
                    
Project file
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 DotNetBrightener.WebApi.GenericCRUD --version 2025.0.9-preview-487
                    
#r "nuget: DotNetBrightener.WebApi.GenericCRUD, 2025.0.9-preview-487"
                    
#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 DotNetBrightener.WebApi.GenericCRUD@2025.0.9-preview-487
                    
#: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=DotNetBrightener.WebApi.GenericCRUD&version=2025.0.9-preview-487&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=DotNetBrightener.WebApi.GenericCRUD&version=2025.0.9-preview-487&prerelease
                    
Install as a Cake Tool

Centralized CRUD WebAPI in ASP.NET Core Applications

© 2025 DotNet Brightener. admin@dotnetbrightener.com

Instruction

Most applications rely on CRUD operations. This library provides core CRUD functionalities, exposing them as WebAPI controllers, utilizing DotNetBrightener.DataAccess.Abstractions library, which facilitates the database access layer performing the CRUD operations.

Implement in your project

Let's say in your project, you have the following class defined:

public class ProductDocument : BaseEntityWithAuditInfo
{
    [MaxLength(255)]
    public string FileName { get; set; }
 
    [MaxLength(1024)]
    public string Description { get; set; }
 
    [MaxLength(2048)]
    public string FileUrl { get; set; }
 
    public Guid? FileGuid { get; set; }
 
    public int? DisplayOrder { get; set; }
 
    [DataType(DataType.Currency)]
    public decimal? Price { get; set; }
}

You will need to create a DataService interface and implementation class like the following:

public partial interface IProductDocumentDataService : IBaseDataService<ProductDocument> { }
 
public partial class ProductDocumentDataService : BaseDataService<ProductDocument>, IProductDocumentDataService {
    
    public ProductDocumentDataService(IRepository repository)
        : base(repository)
    {
    }
}

The IBaseDataService<> interface and BaseDataService<> base class are defined in DotNetBrightener.DataAccess.Abstractions library. They provided CRUD operation already so you will not need to write CRUD operation yourself. The implementation is highly customizable, so you can change the logic based on your application's need.

You can then create a controller as followed:


[ApiController]
[Route("api/[controller]")]
public partial class ProductDocumentController : BaseCRUDController<ProductDocument>
{
    public ProductDocumentController(
            IProductDocumentDataService dataService,
            IHttpContextAccessor httpContextAccessor)
        : base(dataService, httpContextAccessor)
    {
    }
}

In Startup.cs or Program.cs, register your DataService interface and implementation class to the ServiceCollection as followed:

builder.Services.AddScoped<IProductDocumentDataService, ProductDocumentDataService>();

If you use CORS, you will need to add the following to the ConfigureServices method in Startup.cs:


    services.AddCors(options =>
    {
        options.AddPolicy("CorsPolicy",
                            builder =>
                            {
                                // other configurations for your CORS policy builder

                                // builder.AllowAnyMethod()
                                //        .AllowAnyHeader();

                                  
                                // This is required for the headers that returned from the paged list API to be exposed to the consumers
                                builder.AddPagedDataSetExposedHeaders();
                            });
    });

Now your API is available. Check out the next section for the available APIs and what to expect.

Available CRUD APIs

The following API for CRUD will be available when you implement the CRUD controllers.

GET /api/[entity]

  • Retrieve list of records of the entity type, and satisfies the filter, if provided

This API accepts the following query string parameters:

Parameter Type Description
columns string[], separate by commas The columns / fields of the entity to retrieve
pageSize number The number of records to return in one page, default is 20
pageIndex number The index of the page to return, default is 0
orderBy string The column to sort the result by, in ascending order. If the value starts with a hyphen (-) and followed by the column name, the result is sorted in descending order. This parameter impacts how the data is returned.
{column_name} any The filter expressions to filter the result by the column_name. Eg: createdBy=user* will filter the result to return the records that have CreatedBy value starts with user. Or, summary=contains(value3)&createdDate=<=2023-12-01, will filter the records that have summary value contains value3 in the string, and createdDate is before 01 Dec 2023.<br/><br/>See the tables below for more detail.

column_name is case-sensitive. You will need to obtain the correct name of the column from the response body.

There is no OR operator supported at the moment, because the nature of HTTP query strings combined by & operator. Therefore, only AND operator can be supported.

You can use custom queries for the {column_name} parameter with different operators. Here's a table explaining how to use them:

The follow operators are supported in most of all data types, string, int, long, float, double

Operator Symbol Example Usage Description
Equals eq (default) id=eq(100) or id=100 Filters records where the id value matches the one on the right side of the query or in the parentheses.
Not Equals ne id=ne_100 <br /> id=ne(100)<br/> id=!(100) Filters the records where the id value doesn't not equal the value on the right operand or in the parentheses.
In in summary=in(valuea,valueb) Filters the records where the summary is in the values defined in the parentheses.
Not In notin<br /> !in summary=notin(valuea,valueb)<br />summary=!in(valuea,valueb) Filters the records where the summary IS NOT in the values defined in the parentheses.

The following operators are supported for string data type.

Operator Symbol Example Usage Description
Contains contains<br/>like<br/>*keyword* summary=contains(value)<br />summary=like(value)<br />summary=*value* Filters the records where the summary contains the value in the parentheses.
Not Contains notcontains<br/>notlike<br/>!contains<br />!like summary=!contains(value)<br />summary=!like(value) Filters the records where the summary DOES NOT contains the value in the parentheses.
Starts With startsWith<br />sw<br/>keyword* summary=startsWith(value)<br/>summary=sw(value)<br/>summary=value* Filters the records where the summary starts with the value in the parentheses or on the right side of the query.
Not Starts With !startsWith<br />!sw summary=!startsWith(value)<br/>summary=!sw(value) Filters the records where the summary DOES NOT start with the value in the parentheses.
Ends With endsWith<br/>ew<br/>*keyword summary=endsWith(value)<br />summary=ew(value)<br/>summary=*value Filters the records where the summary ends with the value in the parentheses or on the right side of the query.
Not Ends With !endsWith<br/>!ew summary=!endsWith(value)<br />summary=!ew(value) Filters the records where the summary DOES NOT end with the value in the parentheses.

The following operators are supported for int, float, double, decimal, datetime and datetimeoffset data type.

Operator Symbol Example Usage Description
Greater Than<br />After (for datetime types) > gt id=>(10)<br />displayIndex=>(200)<br />expirationDate=>(2023-12-01) -
Greater Than or Equals<br />On or After (for datetime type) >= ge id=>=(10)<br />displayIndex=>=(200)<br />expirationDate=>=(2023-12-01) -
Less Than<br />Before (for datetime types) < lt id=<(10)<br />displayIndex=<(200)<br />invoiceDate=<(2023-12-01)<br />invoiceDate=lt(2023-12-01) -
Less Than or Equals<br />Before or On (for datetime types) <= le id=<=(10)<br />displayIndex=<=(200)<br />invoiceDate=<=(2023-12-01)<br />invoiceDate=le(2023-12-01) -

The following operators are supported for datetimeoffset data type.

Operator Symbol Example Usage Description
ON on expiredDate=on(2024-06-05T00:00:00.000+07:00) Retrieve records that have expiredDate occurs between (inclusively) 00:00:00 and 23:59:59 on the 5th of June, 2024 at timezone +07:00
NOT ON !on noton expiredDate=noton(2024-06-05T00:00:00.000+07:00)<br /><br />expiredDate=!on(2024-06-05T00:00:00.000+07:00) Retrieve records that have expiredDate occurs not on the 5th of June, 2024 at timezone +07:00. It means the result includes records with expiredDate before 12:00AM June 5th, and records with expiredDate after 11:59:59PM June 5th.<br/>It results in same result as of the query expiredDate=!in(2024-06-05T00:00:00.000+07:00,2024-06-05T23:59:59.000+07:00)
IN in expiredDate=in(2024-06-05T00:00:00.000+07:00,2024-06-07T12:30:00.000+07:00) Retrieve records that have expiredDate occurs between the 5th of June, 2024 and 12:30 PM 7th of June, 2024 at timezone +07:00
NOT IN !in notin expiredDate=notin(2024-06-05T00:00:00.000+07:00,2024-06-07T00:00:00.000+07:00)<br /><br />expiredDate=!in(2024-06-05T00:00:00.000+07:00,2024-06-07T12:30:00.000+07:00) Retrieve records that have expiredDate occurs before the 5th of June, 2024 or after 12:30 PM 7th of June, 2024 at timezone +07:00

The response of the API also has the headers as followed that help you identify the total items available, the result count, requested page size and requested page index. See the below table for details.

Header Description
X-Total-Count The total number of items available based on the filter defined in the request
X-Result-Count The number of items returned in the current page
X-Page-Size The requested page size
X-Page-Index The requested page index

GET /api/[entity]/[id]

  • Get the record of the entity type by id

This API accepts the following query string parameters

Parameter Type Description
columns string[], separate by commas The columns / fields of the entity to retrieve

POST /api/[entity]

  • Create a new record of the entity type

PUT /api/[entity]/{id}

  • Update entity by id

The body of the request can be part of the entity. Only the provided fields in the body will be updated to the entity specified by the id

DELETE /api/[entity]/{id}

  • Delete entity by id

PUT /api/[entity]/{id}/undelete

  • Restore the deleted record of the entity by id
Product Compatible and additional computed target framework versions.
.NET net9.0 is compatible.  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.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on DotNetBrightener.WebApi.GenericCRUD:

Package Downloads
DotNetBrightener.LocaleManagement

Package Description

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
2025.0.9-preview-539 52 10/12/2025
2025.0.9-preview-535 172 10/8/2025
2025.0.9-preview-509 209 10/2/2025
2025.0.9-preview-508 188 10/2/2025
2025.0.9-preview-487 208 9/29/2025
2025.0.9-preview-481 182 9/29/2025
2025.0.9-preview-473 174 9/28/2025
2025.0.8 192 9/23/2025
2025.0.6 202 9/22/2025
2025.0.6-preview-455 200 9/22/2025
2025.0.6-preview-454 316 9/17/2025
2025.0.6-preview-441 159 9/14/2025
2025.0.6-preview-440 154 9/14/2025
2025.0.6-preview-406 191 9/2/2025
2025.0.6-preview-401 171 9/2/2025
2025.0.6-preview-400 184 9/2/2025
2025.0.6-preview-369 214 8/27/2025
2025.0.6-preview-368 222 8/27/2025
2025.0.6-preview-334 204 8/18/2025
2025.0.6-preview-333 136 7/27/2025
2025.0.6-preview-332 486 7/24/2025
2025.0.6-preview-331 485 7/24/2025
2025.0.6-preview-328 489 7/24/2025
2025.0.6-preview-327 346 7/21/2025
2025.0.6-preview-326 343 7/21/2025
2025.0.6-preview-325 243 7/20/2025
2025.0.6-preview-324 246 7/20/2025
2025.0.6-preview-322 255 7/20/2025
2025.0.6-preview-321 254 7/19/2025
2025.0.6-preview-320 249 7/19/2025
2025.0.6-preview-319 162 7/17/2025
2025.0.6-preview-317 158 7/17/2025
2025.0.6-preview-316 162 7/17/2025
2025.0.6-preview-315 157 7/17/2025
2025.0.6-preview-314 156 7/17/2025
2025.0.6-preview-313 162 7/17/2025
2025.0.6-preview-312 161 7/16/2025
2025.0.5 192 7/10/2025
2025.0.5-preview-307 91 7/5/2025
2025.0.4 101 7/5/2025
2025.0.4-preview-305 111 7/4/2025
2025.0.4-preview-304 181 7/1/2025
2025.0.4-preview-299 144 5/31/2025
2025.0.4-preview-298 119 5/30/2025
2025.0.4-preview-296 158 5/30/2025
2025.0.4-preview-295 170 5/29/2025
2025.0.4-preview-293 170 5/26/2025
2025.0.4-preview-292 165 5/26/2025
2025.0.3 158 2/10/2025
2025.0.3-preview-288 137 2/10/2025
2025.0.2 167 1/21/2025
2025.0.2-preview-278 105 1/21/2025
2025.0.2-preview-277 139 12/16/2024
2025.0.1-rc-243301701 362 11/25/2024
2024.0.14.6 154 11/25/2024
2024.0.14.6-rc-243031001 176 10/29/2024
2024.0.14.6-rc-243030701 120 10/29/2024
2024.0.14.6-rc-242840501 130 10/10/2024
2024.0.14.6-rc-242820305 126 10/8/2024
2024.0.14.6-rc-242771401 228 10/3/2024
2024.0.14.6-rc-242770501 121 10/3/2024
2024.0.14.6-rc-242770201 163 10/3/2024
2024.0.14.6-rc-242761801 123 10/2/2024
2024.0.14.6-rc-242761601 137 10/2/2024
2024.0.14.6-rc-242761501 120 10/2/2024
2024.0.14.6-rc-242761401 130 10/2/2024
2024.0.14.6-rc-242760701 145 10/2/2024
2024.0.14.6-rc-242751002 114 10/1/2024
2024.0.14.6-rc-242750901 130 10/1/2024
2024.0.14.6-rc-242750502 128 10/1/2024
2024.0.14.6-rc-242750201 126 10/1/2024
2024.0.14.6-rc-242741501 118 9/30/2024
2024.0.14.6-rc-242730701 139 9/29/2024
2024.0.14.6-preview-2730501 121 9/29/2024
2024.0.14.6-preview-2701501 134 9/26/2024
2024.0.14.6-preview-2620901 159 9/18/2024
2024.0.14.6-preview-2570701 113 9/13/2024
2024.0.14.6-preview-2510703 183 9/7/2024
2024.0.14.6-preview-2480501 141 9/4/2024
2024.0.14.6-preview-2430401 147 8/30/2024
2024.0.14.6-preview-242730701 116 9/29/2024
2024.0.14.6-preview-2421703 135 8/29/2024
2024.0.14.6-preview-2421701 127 8/29/2024
2024.0.14.6-preview-2420901 131 8/29/2024
2024.0.14.6-preview-2390101 149 8/26/2024
2024.0.14.6-preview-2381603 135 8/25/2024
2024.0.14.6-preview-2341601 154 8/21/2024
2024.0.14.6-preview-2321602 149 8/20/2024
2024.0.14.6-preview-2190801 180 8/6/2024
2024.0.14.6-preview-2041501 128 7/22/2024
2024.0.14.6-preview-1920603 196 7/10/2024
2024.0.14.6-preview-1920301 135 7/10/2024
2024.0.14.6-preview-1911302 154 7/9/2024
2024.0.14.6-preview-1901001 157 7/8/2024
2024.0.14.6-preview-1900901 146 7/8/2024
2024.0.14.6-preview-1900801 137 7/8/2024
2024.0.14.6-preview-1860304 141 7/4/2024
2024.0.14.5 215 7/1/2024
2024.0.14.5-preview-1811601 142 6/29/2024
2024.0.14.5-preview-1810501 156 6/29/2024
2024.0.14.5-preview-180132 121 6/28/2024
2024.0.14.5-preview-180131 131 6/28/2024
2024.0.14.5-preview-180121 114 6/28/2024
2024.0.14.4 170 6/27/2024
2024.0.14.4-preview-7 159 6/27/2024
2024.0.14.3 156 6/21/2024
2024.0.14.1 180 6/6/2024
2024.0.14.1-preview 124 6/6/2024
2024.0.13.8-preview 136 6/6/2024
2024.0.13.1-preview-0146 123 6/6/2024
2024.0.12.15803-preview-03 132 6/6/2024
2024.0.12.15608 178 6/4/2024
2024.0.12.15515 260 6/3/2024
2024.0.12.15220 180 5/31/2024
2024.0.12.15220-alpha31-240... 119 5/31/2024
2024.0.12.14911 230 5/28/2024
2024.0.12.14910-alpha28-240... 136 5/28/2024
2024.0.12.14823 173 5/27/2024
2024.0.12.14522-alpha7-2405... 143 5/24/2024
2024.0.12.14514-alpha6-2405... 125 5/24/2024
2024.0.12.14511 170 5/24/2024
2024.0.12.14314 188 5/22/2024
2024.0.12.14114 180 5/20/2024
2024.0.12.12815 218 5/7/2024
2024.0.12.12814 184 5/7/2024
2024.0.12.12721 207 5/6/2024
2024.0.12.12702 196 5/5/2024
2024.0.12.12622 207 5/5/2024
2024.0.12.12514 196 5/4/2024
2024.0.12.12512 159 5/4/2024
2024.0.12.12510 193 5/4/2024
2024.0.12.12420 176 5/3/2024
2024.0.12.12319 131 5/2/2024
2024.0.12.12319-rc-2405021801 94 5/2/2024
2024.0.12.12318 144 5/2/2024
2024.0.12.12215 169 5/1/2024
2024.0.12.12011 190 4/29/2024
2024.0.12.11720 198 4/26/2024
2024.0.12.11719 179 4/26/2024
2024.0.12.11621 197 4/25/2024
2024.0.12.11523 165 4/24/2024
2024.0.12.11522 162 4/24/2024
2024.0.12.11417 201 4/23/2024
2024.0.12.11400 171 4/22/2024
2024.0.12.11316 184 4/22/2024
2024.0.11.10220 166 4/11/2024
2024.0.11.10120 174 4/10/2024
2024.0.11.10119 160 4/10/2024
2024.0.11.10115 167 4/10/2024
2024.0.11.9914 210 4/8/2024
2024.0.11.9901 188 4/7/2024
2024.0.11.9823 181 4/7/2024
2024.0.11.9401 201 4/2/2024
2024.0.11.9301 186 4/1/2024
2024.0.11.9206 199 3/31/2024
2024.0.11.9205 191 3/31/2024
2024.0.11.8200 194 3/21/2024
2024.0.11.8122 160 3/21/2024
2024.0.11.8120 181 3/21/2024
2024.0.11.7320 227 3/13/2024
2024.0.11.7316 221 3/13/2024
2024.0.11.7310 172 3/13/2024
2024.0.11 178 3/13/2024
2024.0.10 222 3/3/2024
2024.0.9 186 2/27/2024
2024.0.8 244 2/1/2024
2024.0.7 184 1/26/2024
2024.0.6 171 1/25/2024
2024.0.5 159 1/24/2024
2024.0.4 159 1/24/2024
2024.0.3 191 1/22/2024
2024.0.2 237 1/10/2024
2024.0.1 222 1/9/2024
2024.0.1-alpha-3 145 1/9/2024
2024.0.1-alpha-2 167 1/9/2024
2024.0.1-alpha-1 170 1/3/2024
2024.0.0 244 12/26/2023
2023.0.27 210 12/21/2023
2023.0.26 166 12/21/2023
2023.0.25 209 12/11/2023
2023.0.24 181 12/8/2023
2023.0.23 172 12/6/2023
2023.0.21 197 12/4/2023
2023.0.20 213 11/27/2023
2023.0.19 174 11/20/2023
2023.0.18 198 10/25/2023
2023.0.17 244 10/22/2023
2023.0.16 203 10/16/2023
2023.0.16-alpha-1 144 10/16/2023
2023.0.15 209 10/14/2023
2023.0.14 182 10/14/2023
2023.0.13 193 10/14/2023
2023.0.12 189 10/14/2023
2023.0.11 185 10/10/2023
2023.0.10 189 10/9/2023
2023.0.9 230 8/16/2023
2023.0.8 204 8/15/2023
2023.0.8-alpha-2 281 5/31/2023
2023.0.7 235 5/12/2023
2023.0.6 397 5/10/2023
2023.0.5 221 5/7/2023
2023.0.4 246 4/22/2023
2023.0.3 298 4/19/2023
2023.0.2 300 4/6/2023
2023.0.1 292 3/13/2023
2022.11.0 431 11/21/2022
2022.10.2 450 11/9/2022
2022.10.1 451 10/28/2022