This library is designed to support the backend functionalities required by the Flexi Report Angular library.
- Report Management: Create, edit, and manage reports.
- Dynamic SQL Queries: Retrieve data from the database with dynamic queries.
- Database Schema Retrieval: List tables and columns from the database.
- Flexible and Customizable: Supports dynamic components generated on the UI side.
To add this package to your project, run:
dotnet add package FlexiReportRetrieve all tables and columns from the connected database:
public async Task<List<DatabaseSchemaDto>> GetDatabaseSchemaAsync(DbContext dbContext, CancellationToken cancellationToken = default)Example Usage:
var schema = await flexiReportService.GetDatabaseSchemaAsync(dbContext);Only SELECT queries are allowed.
public async Task<Result<object>> ExecuteQueryAsync(QueryRequestDto request, DbContext dbContext, CancellationToken cancellationToken = default)Example Usage:
var request = new QueryRequestDto("SELECT * FROM Users");
var result = await flexiReportService.ExecuteQueryAsync(request, dbContext);The Report model contains the following properties:
public sealed class Report
{
public Guid Id { get; set; }
public string Content { get; set; }
public DateTime CreatedAt { get; set; }
public string Endpoint { get; set; }
public string Name { get; set; }
public string PageSize { get; set; }
public string PageOrientation { get; set; }
public string FontFamily { get; set; }
public string SqlQuery { get; set; }
public string BackgroundColor { get; set; }
public List<RequestElement>? RequestElements { get; set; }
}To integrate with the frontend, use the following API structure:
[HttpPost("execute-query")]
public async Task<IActionResult> ExecuteQuery([FromBody] QueryRequestDto request)
{
var result = await _flexiReportService.ExecuteQueryAsync(request, _dbContext);
return result.IsSuccess ? Ok(result.Value) : BadRequest(result.Error);
}public sealed record QueryRequestDto(
string SqlQuery);public sealed record ReportDto(
Guid? Id,
string Content,
string Endpoint,
string Name,
string PageSize,
string PageOrientation,
string FontFamily,
string SqlQuery,
string BackgroundColor,
List<RequestElementDto> RequestElements);Distributed under the MIT License.