From 88b70689f9ede1c32d308eabc8b7e84d5542f8ed Mon Sep 17 00:00:00 2001 From: yv989c Date: Fri, 19 May 2023 17:24:10 -0400 Subject: [PATCH] perf: xml query refactoring Benchmark shows perf. boost for the String data type on big collections. --- .../SqlServer/XmlQueryableFactory.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/QueryableValues.SqlServer/SqlServer/XmlQueryableFactory.cs b/src/QueryableValues.SqlServer/SqlServer/XmlQueryableFactory.cs index 292f250..77de03e 100644 --- a/src/QueryableValues.SqlServer/SqlServer/XmlQueryableFactory.cs +++ b/src/QueryableValues.SqlServer/SqlServer/XmlQueryableFactory.cs @@ -41,7 +41,7 @@ protected override string GetSqlForComplexTypes(IEntityOptionsBuilder entityOpti sb .Append("\tI.value('@") .Append(QueryableValuesEntity.IndexPropertyName) - .Append("[1] cast as xs:integer?', 'int') AS [") + .Append(" cast as xs:integer?', 'int') AS [") .Append(QueryableValuesEntity.IndexPropertyName) .Append(']'); @@ -54,7 +54,7 @@ protected override string GetSqlForComplexTypes(IEntityOptionsBuilder entityOpti var targetName = mapping.Target.Name; - sb.Append("\tI.value('@").Append(targetName).Append("[1] cast as "); + sb.Append("\tI.value('@").Append(targetName).Append(" cast as "); switch (mapping.TypeName) { @@ -122,7 +122,7 @@ protected override string GetSqlForComplexTypes(IEntityOptionsBuilder entityOpti } sb.AppendLine(); - sb.Append("FROM {0}.nodes('/R/V') N(I)").AppendLine(); + sb.Append("FROM {0}.nodes('/R[1]/V') N(I)").AppendLine(); sb.Append("ORDER BY [").Append(QueryableValuesEntity.IndexPropertyName).Append(']'); return sb.ToString();