diff --git a/src/SmartSql.DyRepository/EmitRepositoryBuilder.cs b/src/SmartSql.DyRepository/EmitRepositoryBuilder.cs index 0a5fa804..5471066a 100644 --- a/src/SmartSql.DyRepository/EmitRepositoryBuilder.cs +++ b/src/SmartSql.DyRepository/EmitRepositoryBuilder.cs @@ -314,7 +314,6 @@ private Statement PreStatement(Type interfaceType, SqlMap sqlMap, MethodInfo met throw new SmartSqlException($"Statement.FullSqlId:[{fullSqlId}] already exists!"); } - var resultCacheAttr = methodInfo.GetCustomAttribute(); statement = new Statement { SqlMap = sqlMap, @@ -339,15 +338,18 @@ private Statement PreStatement(Type interfaceType, SqlMap sqlMap, MethodInfo met statement.SourceChoice = statementAttr.SourceChoice; } - if (resultCacheAttr != null) - { - statement.CacheId = ParseCacheFullId(sqlMap.Scope, resultCacheAttr.CacheId); - statement.Cache = sqlMap.GetCache(statement.CacheId); - } - sqlMap.Statements.Add(statement.FullSqlId, statement); + + } + + var resultCacheAttr = methodInfo.GetCustomAttribute(); + if (resultCacheAttr != null) + { + statement.CacheId = ParseCacheFullId(sqlMap.Scope, resultCacheAttr.CacheId); + statement.Cache = sqlMap.GetCache(statement.CacheId); } + returnType = isTaskReturnType ? returnType.GetGenericArguments().FirstOrDefault() : returnType; if (returnType == typeof(DataTable)) { diff --git a/src/SmartSql/CUD/CUDSqlGenerator.cs b/src/SmartSql/CUD/CUDSqlGenerator.cs index 9a995447..1b798b86 100644 --- a/src/SmartSql/CUD/CUDSqlGenerator.cs +++ b/src/SmartSql/CUD/CUDSqlGenerator.cs @@ -2,9 +2,13 @@ using SmartSql.Configuration; using SmartSql.Configuration.Tags; using SmartSql.DataSource; +using SmartSql.Reflection.TypeConstants; using SmartSql.Utils; using System; +using System.Collections.Concurrent; using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Text; namespace SmartSql.CUD { @@ -33,6 +37,8 @@ public CUDSqlGenerator(SmartSqlConfig config) _analyzer = new StatementAnalyzer(); } + + private Statement BuildStatement(string statementId, string sql, SqlMap sqlMap) { return new Statement()