-
Notifications
You must be signed in to change notification settings - Fork 1
LNK-4316: Handle Legacy QueryPlans in Converter #1244
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
nvmLantana
merged 4 commits into
dev
from
nvm/LNK-4316_HandleLegacyQueryPlansInConverter
Nov 7, 2025
Merged
Changes from 3 commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 0 additions & 34 deletions
34
DotNet/DataAcquisition.Domain/Application/Serializers/QueryConfigConverter.cs
This file was deleted.
Oops, something went wrong.
65 changes: 65 additions & 0 deletions
65
DotNet/DataAcquisition.Domain/Application/Serializers/QueryPlanConverter.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| using LantanaGroup.Link.DataAcquisition.Domain.Infrastructure.Interfaces; | ||
| using LantanaGroup.Link.DataAcquisition.Domain.Infrastructure.Models.QueryConfig; | ||
| using System.Text.Json; | ||
| using System.Text.Json.Serialization; | ||
|
|
||
| namespace LantanaGroup.Link.DataAcquisition.Domain.Application.Serializers; | ||
|
|
||
| public class QueryPlanConverter : JsonConverter<IQueryConfig> | ||
| { | ||
| public override IQueryConfig Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) | ||
| { | ||
| using (JsonDocument doc = JsonDocument.ParseValue(ref reader)) | ||
| { | ||
| JsonElement typeElement; | ||
| string configType = null; | ||
|
|
||
| if (doc.RootElement.TryGetProperty("QueryConfigType", out typeElement) || | ||
| doc.RootElement.TryGetProperty("queryConfigType", out typeElement)) | ||
| { | ||
| configType = typeElement.GetString(); | ||
| } | ||
| else if (doc.RootElement.TryGetProperty("$type", out typeElement)) | ||
| { | ||
| var typeName = typeElement.GetString(); | ||
| if (typeName?.Contains("ParameterQueryConfig") == true) | ||
| { | ||
| configType = "Parameter"; | ||
| } | ||
| else if (typeName?.Contains("ReferenceQueryConfig") == true) | ||
| { | ||
| configType = "Reference"; | ||
| } | ||
| } | ||
|
|
||
| if (configType == null) | ||
| { | ||
| // Fallback to property inspection if no type discriminator is found | ||
| if (doc.RootElement.TryGetProperty("Parameters", out _)) | ||
| { | ||
| configType = "Parameter"; | ||
| } | ||
| else if (doc.RootElement.TryGetProperty("Paged", out _)) | ||
| { | ||
| configType = "Reference"; | ||
| } | ||
| else | ||
| { | ||
| throw new JsonException("Unable to determine QueryConfigType. Missing type discriminator or distinguishing properties."); | ||
| } | ||
| } | ||
|
|
||
| return configType switch | ||
| { | ||
| "Parameter" => JsonSerializer.Deserialize<ParameterQueryConfig>(doc.RootElement.GetRawText(), options), | ||
| "Reference" => JsonSerializer.Deserialize<ReferenceQueryConfig>(doc.RootElement.GetRawText(), options), | ||
| _ => throw new JsonException($"Unknown QueryConfigType: {configType}") | ||
| }; | ||
| } | ||
| } | ||
|
|
||
| public override void Write(Utf8JsonWriter writer, IQueryConfig value, JsonSerializerOptions options) | ||
| { | ||
| JsonSerializer.Serialize(writer, value, value.GetType(), options); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.