From 846b5362ba7c3bb05de59e18eb397ea512ae249c Mon Sep 17 00:00:00 2001 From: Ahoo Date: Thu, 19 Jul 2018 10:30:41 +0800 Subject: [PATCH] 1. optimize the SqlMap.xml reading directory 2. remove Strong type Statement --- doc/Schemas/SmartSqlMap.xsd | 120 ------------------ .../Abstractions/ConfigLoader/ConfigLoader.cs | 12 -- .../Configuration/Statements/Delete.cs | 11 -- .../Configuration/Statements/Insert.cs | 12 -- .../Configuration/Statements/Select.cs | 11 -- .../Configuration/Statements/Statement.cs | 15 +-- .../Configuration/Statements/Update.cs | 11 -- src/SmartSql/LocalFileConfigLoader.cs | 3 +- src/SmartSql/SmartSql.csproj | 5 +- 9 files changed, 12 insertions(+), 188 deletions(-) delete mode 100644 src/SmartSql/Configuration/Statements/Delete.cs delete mode 100644 src/SmartSql/Configuration/Statements/Insert.cs delete mode 100644 src/SmartSql/Configuration/Statements/Select.cs delete mode 100644 src/SmartSql/Configuration/Statements/Update.cs diff --git a/doc/Schemas/SmartSqlMap.xsd b/doc/Schemas/SmartSqlMap.xsd index 723d748d..80dad64f 100644 --- a/doc/Schemas/SmartSqlMap.xsd +++ b/doc/Schemas/SmartSqlMap.xsd @@ -751,130 +751,10 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/SmartSql/Abstractions/ConfigLoader/ConfigLoader.cs b/src/SmartSql/Abstractions/ConfigLoader/ConfigLoader.cs index d7a79214..3f26ae47 100644 --- a/src/SmartSql/Abstractions/ConfigLoader/ConfigLoader.cs +++ b/src/SmartSql/Abstractions/ConfigLoader/ConfigLoader.cs @@ -89,18 +89,6 @@ public SmartSqlMap LoadSmartSqlMap(ConfigStream configStream) #region Init Statement var statementNodes = xmlDoc.SelectNodes("//ns:Statement", xmlNsM); LoadStatementInSqlMap(sqlMap, statementNodes); - - var insertNodes = xmlDoc.SelectNodes("//ns:Insert", xmlNsM); - LoadStatementInSqlMap(sqlMap, insertNodes); - - var updateNodes = xmlDoc.SelectNodes("//ns:Update", xmlNsM); - LoadStatementInSqlMap(sqlMap, updateNodes); - - var deleteNodes = xmlDoc.SelectNodes("//ns:Delete", xmlNsM); - LoadStatementInSqlMap(sqlMap, deleteNodes); - - var selectNodes = xmlDoc.SelectNodes("//ns:Select", xmlNsM); - LoadStatementInSqlMap(sqlMap, selectNodes); #endregion return sqlMap; diff --git a/src/SmartSql/Configuration/Statements/Delete.cs b/src/SmartSql/Configuration/Statements/Delete.cs deleted file mode 100644 index c5760c0e..00000000 --- a/src/SmartSql/Configuration/Statements/Delete.cs +++ /dev/null @@ -1,11 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace SmartSql.Configuration.Statements -{ - public class Delete : Statement - { - public override StatementType Type => StatementType.Delete; - } -} diff --git a/src/SmartSql/Configuration/Statements/Insert.cs b/src/SmartSql/Configuration/Statements/Insert.cs deleted file mode 100644 index 0cb7ca7a..00000000 --- a/src/SmartSql/Configuration/Statements/Insert.cs +++ /dev/null @@ -1,12 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace SmartSql.Configuration.Statements -{ - public class Insert : Statement - { - public override StatementType Type => StatementType.Insert; - //public bool ReturnPrimaryKey { get; set; } - } -} diff --git a/src/SmartSql/Configuration/Statements/Select.cs b/src/SmartSql/Configuration/Statements/Select.cs deleted file mode 100644 index 9fd5b775..00000000 --- a/src/SmartSql/Configuration/Statements/Select.cs +++ /dev/null @@ -1,11 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace SmartSql.Configuration.Statements -{ - public class Select : Statement - { - public override StatementType Type => StatementType.Select; - } -} diff --git a/src/SmartSql/Configuration/Statements/Statement.cs b/src/SmartSql/Configuration/Statements/Statement.cs index 2779eb98..e4d19950 100644 --- a/src/SmartSql/Configuration/Statements/Statement.cs +++ b/src/SmartSql/Configuration/Statements/Statement.cs @@ -11,16 +11,15 @@ namespace SmartSql.Configuration.Statements { public enum StatementType { - Statement, - Insert, - Update, - Delete, - Select + Insert = 1 << 0, + Update = 1 << 1, + Delete = 1 << 2, + Select = 1 << 3 } public class Statement { - public virtual StatementType Type { get { return StatementType.Statement; } } + public virtual StatementType Type { get; internal set; } [XmlIgnore] public SmartSqlMap SmartSqlMap { get; internal set; } [XmlAttribute] @@ -28,8 +27,8 @@ public class Statement public String FullSqlId => $"{SmartSqlMap.Scope}.{Id}"; public IList SqlTags { get; set; } public Cache Cache { get; set; } - public ResultMap ResultMap { get; set; } - public ParameterMap ParameterMap { get; set; } + public ResultMap ResultMap { get; set; } + public ParameterMap ParameterMap { get; set; } public void BuildSql(RequestContext context) { diff --git a/src/SmartSql/Configuration/Statements/Update.cs b/src/SmartSql/Configuration/Statements/Update.cs deleted file mode 100644 index c46b71fa..00000000 --- a/src/SmartSql/Configuration/Statements/Update.cs +++ /dev/null @@ -1,11 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace SmartSql.Configuration.Statements -{ - public class Update : Statement - { - public override StatementType Type => StatementType.Update; - } -} diff --git a/src/SmartSql/LocalFileConfigLoader.cs b/src/SmartSql/LocalFileConfigLoader.cs index 57732e8c..cf547a4e 100644 --- a/src/SmartSql/LocalFileConfigLoader.cs +++ b/src/SmartSql/LocalFileConfigLoader.cs @@ -54,7 +54,8 @@ public override SmartSqlMapConfig Load() } case SmartSqlMapSource.ResourceType.Directory: { - var childSqlmapSources = Directory.EnumerateFiles(sqlMapSource.Path, "*.xml"); + var dicPath = Path.Combine(AppContext.BaseDirectory, sqlMapSource.Path); + var childSqlmapSources = Directory.EnumerateFiles(dicPath, "*.xml"); foreach (var childSqlmapSource in childSqlmapSources) { LoadSmartSqlMapAndInConfig(childSqlmapSource); diff --git a/src/SmartSql/SmartSql.csproj b/src/SmartSql/SmartSql.csproj index c23cb2f3..56146327 100644 --- a/src/SmartSql/SmartSql.csproj +++ b/src/SmartSql/SmartSql.csproj @@ -11,10 +11,11 @@ https://github.com/Ahoo-Wang/SmartSql https://github.com/Ahoo-Wang/SmartSql False - 3.4.2 + 3.4.3 orm sql read-write-separation cache redis dotnet-core cross-platform high-performance distributed-computing zookeeper - 1. Optimize the resource reading directory + 1. Optimize the SqlMap.xml reading directory + 2. remove Strong type Statement https://raw.githubusercontent.com/Ahoo-Wang/SmartSql/master/SmartSql.png https://raw.githubusercontent.com/Ahoo-Wang/SmartSql/master/LICENSE