Data Export
Files Referenced in this Document
IMyEntityNameAppService.csMyEntityNameAppService.csMyEntityNameExcelDto.cs
Table of Contents
Introduction
Data export allows users to download system data into an Excel file for reporting, backup, or analysis in external tools.
Export Logic (ExportAsync)
Method Signature: Task<FileContentResult> ExportAsync(MyEntityNameGetListInput input)
Process:
- Query: Accepts
MyEntityNameGetListInputto filter the data to be exported (e.g., export only "Active" items). - Fetch: Retrieves the filtered data from the database. Note that unlike paging, this might fetch a larger dataset or all matching records.
- Map: Converts Entities to
MyEntityNameExcelDto. - Generate: Uses the Excel library to write the DTOs into an Excel sheet.
- Return: Returns the file content as a binary stream with the correct MIME type (
application/vnd.openxmlformats-officedocument.spreadsheetml.sheet).
Filtering and Selection
The export function reuses the same input DTO (MyEntityNameGetListInput) as the list API. This ensures that "what you see is what you get" — users can filter the list on the UI and export exactly those results.
Performance and Security
- Memory Usage: Exporting huge datasets can consume significant memory. Implementations should consider streaming or limiting export size.
- Permissions: Export operations should be protected by permissions (e.g.,
MyPluginName.MyEntityNames.Export) to prevent unauthorized data exfiltration.