Feature: Sql Query Results Handling #153#154
Conversation
veraw
commented
May 22, 2026
- Enhances SqlQuery to allow other Results output types / formats other than DataSet (Easier handling/transforming of queried data within workflow)
- Support output Queried Results as Array of Objects (Dictionary<string,object?>[]) - RecordSet
- Provide ability to add / register other custom Result handlers if required
- Add Unit Tests (Elsa.Sql.Tests) to check DataSet and RecordSet result handling
…entRecordSetResultHandler)
|
PR author is not in the allowed authors list. |
|
@veraw please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.
Contributor License AgreementContribution License AgreementThis Contribution License Agreement ( “Agreement” ) is agreed to by the party signing below ( “You” ), 1. Definitions. “Code” means the computer software code, whether in human-readable or machine-executable form, “Project” means any of the projects owned or managed by .NET Foundation and offered under a license “Submit” is the act of uploading, submitting, transmitting, or distributing code or other content to any “Submission” means the Code and any other copyrightable material Submitted by You, including any 2. Your Submission. You must agree to the terms of this Agreement before making a Submission to any 3. Originality of Work. You represent that each of Your Submissions is entirely Your 4. Your Employer. References to “employer” in this Agreement include Your employer or anyone else 5. Licenses. a. Copyright License. You grant .NET Foundation, and those who receive the Submission directly b. Patent License. You grant .NET Foundation, and those who receive the Submission directly or c. Other Rights Reserved. Each party reserves all rights not expressly granted in this Agreement. 6. Representations and Warranties. You represent that You are legally entitled to grant the above 7. Notice to .NET Foundation. You agree to notify .NET Foundation in writing of any facts or 8. Information about Submissions. You agree that contributions to Projects and information about 9. Governing Law/Jurisdiction. This Agreement is governed by the laws of the State of Washington, and 10. Entire Agreement/Assignment. This Agreement is the entire agreement between the parties, and .NET Foundation dedicates this Contribution License Agreement to the public domain according to the Creative Commons CC0 1. |
There was a problem hiding this comment.
Pull request overview
This PR extends the SQL module’s SqlQuery activity to support pluggable query-result output formats beyond DataSet, enabling workflows to receive transformed result shapes (e.g., “RecordSet”) via registered result handlers.
Changes:
- Adds result-type handler abstractions (provider + factory + handler interface) and registers default
DataSet/RecordSethandlers. - Updates
SqlQueryto select a result handler by a newResultsTypeinput and emit handled results. - Introduces a new
Elsa.Sql.Teststest project with unit tests for theDataSetandRecordSethandlers.
Reviewed changes
Copilot reviewed 16 out of 18 changed files in this pull request and generated 13 comments.
Show a summary per file
| File | Description |
|---|---|
| test/modules/sql/Elsa.Sql.Tests/Handlers/SqlClientRecordSetResultHandlerTests.cs | Adds unit tests for RecordSet result transformation. |
| test/modules/sql/Elsa.Sql.Tests/Handlers/SqlClientDataSetResultHandlerTests.cs | Adds unit tests for DataSet passthrough behavior. |
| test/modules/sql/Elsa.Sql.Tests/GlobalUsings.cs | New (currently empty) test project global usings file. |
| test/modules/sql/Elsa.Sql.Tests/FodyWeavers.xml | Adds ConfigureAwait.Fody weaver config to the test project. |
| test/modules/sql/Elsa.Sql.Tests/Elsa.Sql.Tests.csproj | Adds new SQL test project referencing Elsa.Sql. |
| src/modules/sql/Elsa.Sql/UIHints/SqlClientResultTypesDropDownProvider.cs | Adds dropdown provider to list registered result types in the UI. |
| src/modules/sql/Elsa.Sql/Services/ClientStore.cs | Extends the store to register/track result-type handlers. |
| src/modules/sql/Elsa.Sql/Providers/SqlClientResultTypesProvider.cs | Adds provider to expose registered result types for UI/consumers. |
| src/modules/sql/Elsa.Sql/Handlers/SqlClientRecordSetResultHandler.cs | Implements RecordSet handler that maps a single DataTable to dictionaries. |
| src/modules/sql/Elsa.Sql/Handlers/SqlClientDataSetResultHandler.cs | Implements DataSet handler that passes through the DataSet result. |
| src/modules/sql/Elsa.Sql/Features/SqlFeature.cs | Registers default result handlers and new factory/provider services. |
| src/modules/sql/Elsa.Sql/Factory/SqlClientResultTypeFactory.cs | Adds DI-based factory to instantiate a result handler by name. |
| src/modules/sql/Elsa.Sql/Contracts/ISqlClientResultTypesProvider.cs | Defines contract for listing registered SQL result types. |
| src/modules/sql/Elsa.Sql/Contracts/ISqlClientResultTypeHandler.cs | Defines contract for transforming query results. |
| src/modules/sql/Elsa.Sql/Contracts/ISqlClientResultTypeFactory.cs | Defines contract for creating result handlers by name. |
| src/modules/sql/Elsa.Sql/Activities/SqlQuery.cs | Adds ResultsType input and routes query results through a handler. |
| Elsa.Extensions.sln | Adds the new SQL test project and updates solution metadata/config mappings. |
| .gitignore | Broadens sqlite db ignore pattern to include suffixed variants. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if (clientRegistry.ResultTypes.Count == 0) | ||
| clientRegistry.RegisterResultHandler<SqlClientRecordSetResultHandler>(SqlClientRecordSetResultHandler.Name); | ||
|
|
| using System.Net.Sockets; | ||
| using Elsa.Sql.Client; | ||
| using Elsa.Sql.Contracts; |
| public void RegisterResultHandler<TResultHandler>(string? name) where TResultHandler : class, ISqlClientResultTypeHandler | ||
| { | ||
| var key = string.IsNullOrEmpty(name) ? nameof(TResultHandler) : name; | ||
| if (resultTypes.ContainsKey(key)) { throw new InvalidOperationException($"Result type handler with key '{key}' is already registered."); } | ||
| resultTypes.Add(key, typeof(TResultHandler)); | ||
| } |
| IEnumerable<DataColumn> columns = dataTable.Columns.Cast<DataColumn>(); | ||
| foreach (DataRow dr in dataTable.Rows) | ||
| { | ||
| Dictionary<string, object?> row = new (dataTable.Columns.Count); | ||
| row.AddRange(dataTable.Columns.Cast<DataColumn>().Select(col => |
| {C2721BCB-2FB1-9227-AABB-ED768EB292FD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
| {C2721BCB-2FB1-9227-AABB-ED768EB292FD}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
| {C2721BCB-2FB1-9227-AABB-ED768EB292FD}.Debug|x64.ActiveCfg = Debug|Any CPU |
| {159E73C1-60F9-0D39-9CA1-79EC99187FDC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
| {159E73C1-60F9-0D39-9CA1-79EC99187FDC}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
| {159E73C1-60F9-0D39-9CA1-79EC99187FDC}.Debug|x64.ActiveCfg = Debug|Any CPU |
| using Elsa.Sql.Handlers; | ||
| using Microsoft.Extensions.Logging; |
| using Elsa.Sql.Handlers; | ||
| using Microsoft.Extensions.Logging; |
| <Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd"> | ||
| <ConfigureAwait /> | ||
| </Weavers> No newline at end of file |
|
Closes #153 |
|
@KnibbsyMan Sorry for the delay.... Since I needed to get approval for the license/cla based on my involvement with my company.. which I have... but upon further thought on the issue (feature)... I have added the following issue as a more general /opt-in approach (see: elsa-workflows/elsa-core#7770) that if approved, would allow across-activity conversion support, rather than just specific to the SQL extension module. (I have a partially worked on approach, not finished, but as mentioned in the issue, would require enhancements to elsa-core, elsa-studio aswell as an opt in extension module) Which I would see more beneficial, once implemented, than this PR. (Suggestion would be to not approve this PR, in favour of the more general approach) |