diff --git a/src/NuClear.Dapper.UnitTest/OrderSqlResource.cs b/src/NuClear.Dapper.UnitTest/OrderSqlResource.cs index dbbd083..5fd5f08 100644 --- a/src/NuClear.Dapper.UnitTest/OrderSqlResource.cs +++ b/src/NuClear.Dapper.UnitTest/OrderSqlResource.cs @@ -1,7 +1,5 @@ -using System; -using System.Collections.Generic; -using System.Text; -using NuClear.Dapper.SqlResources; +using NuClear.Dapper.SqlResources; +using System; namespace NuClear.Dapper.UnitTest { diff --git a/src/NuClear.Dapper.UnitTest/OrderSqlResource.xml b/src/NuClear.Dapper.UnitTest/OrderSqlResource.xml index 01bb798..e5b81f3 100644 --- a/src/NuClear.Dapper.UnitTest/OrderSqlResource.xml +++ b/src/NuClear.Dapper.UnitTest/OrderSqlResource.xml @@ -12,7 +12,7 @@ SELECT * FROM dbo.NoteItems ni WITH(NOLOCK) INNER JOIN dbo.OrderOutStockNote o WITH(NOLOCK) ON ni.OrderOutStockNote_Id = o.Id AND o.City_Id=@CityId AND o.AuditState=9 AND o.IsDeleted =0 AND o.UserStatus = 0 AND (YEAR(o.BusinessTime)=@Year AND MONTH(o.BusinessTime)=@Month) AND ni.SaleMode IN (1,3,9) @SaleMode=ni.SaleMode AND @SettlementType = ni.SettlementType AND @FinancialBusinessType=o.FinancialBusinessType AND @StoreHouseId=o.StoreHouse_Id AND o.StoreHouse_Id in @StoreHouseIds OPTION(RECOMPILE) - select * from Orders o with(nolock) where 1 = 1 and Id = @Id and NoteNo = @NoteNo and BusinessTime >= '2022-8-1' + select * from Orders o with(nolock) where 1 = 1 and Id = @Id and NoteNo = @NoteNo and BusinessTime >= '2022-8-1' select * from Orders o with(nolock) where 1 = 1 and Id = @Id and noteno=@NoteNo and UserStatus = 1 and BusinessTime >= '2022-8-1' diff --git a/src/NuClear.Dapper/SqlResources/Scripting/XElementExtensions.cs b/src/NuClear.Dapper/SqlResources/Scripting/XElementExtensions.cs index f39ed26..d005486 100644 --- a/src/NuClear.Dapper/SqlResources/Scripting/XElementExtensions.cs +++ b/src/NuClear.Dapper/SqlResources/Scripting/XElementExtensions.cs @@ -16,7 +16,11 @@ static XElementExtensions() internal static INodeHandler GetNodeHandler(string nodeName) { - return _nodeHandlerMap[nodeName]; + if (_nodeHandlerMap.TryGetValue(nodeName, out var handler)) + { + return handler; + } + throw new SqlParseException($"不识别的ElementName:{nodeName}"); } private static void InitNodeHandlerMap() @@ -37,13 +41,13 @@ public static MixedSqlNode ParseDynamicTags(this XElement node) XNode child = children[i]; if (child.NodeType == System.Xml.XmlNodeType.Text || child.NodeType == System.Xml.XmlNodeType.CDATA) { - TextSqlNode textSqlNode = new TextSqlNode(((System.Xml.Linq.XText)child).Value); + TextSqlNode textSqlNode = new TextSqlNode(((XText)child).Value); contents.Add(textSqlNode); } else if (child.NodeType == System.Xml.XmlNodeType.Element) { var elementNode = XElement.Parse(child.ToString()); - var nodeName = elementNode.Name.ToString(); + var nodeName = elementNode.Name.ToString().ToLower(); INodeHandler handler = GetNodeHandler(nodeName) ?? throw new SqlParseException($"不识别的ElementName:{nodeName}!"); handler.HandleNode(elementNode, contents); }