diff --git a/build/version.props b/build/version.props index c64c92ca..4ad51021 100644 --- a/build/version.props +++ b/build/version.props @@ -2,7 +2,7 @@ 4 1 - 54 + 55 $(VersionMajor).$(VersionMinor).$(VersionPatch) diff --git a/sample/SmartSql.Sample.AspNetCore/Maps/User.xml b/sample/SmartSql.Sample.AspNetCore/Maps/User.xml index 9af1d76b..4da05ffe 100644 --- a/sample/SmartSql.Sample.AspNetCore/Maps/User.xml +++ b/sample/SmartSql.Sample.AspNetCore/Maps/User.xml @@ -18,6 +18,7 @@ + @@ -96,6 +97,7 @@ Limit @PageSize Offset 0; Select Count(1) From T_User T ; + Select 'SmartSql'; diff --git a/sample/SmartSql.Sample.AspNetCore/SmartSql.Sample.AspNetCore.csproj b/sample/SmartSql.Sample.AspNetCore/SmartSql.Sample.AspNetCore.csproj index 4a080657..1a7be36e 100644 --- a/sample/SmartSql.Sample.AspNetCore/SmartSql.Sample.AspNetCore.csproj +++ b/sample/SmartSql.Sample.AspNetCore/SmartSql.Sample.AspNetCore.csproj @@ -9,6 +9,8 @@ + + diff --git a/sample/SmartSql.Sample.AspNetCore/Startup.cs b/sample/SmartSql.Sample.AspNetCore/Startup.cs index 55e0a527..0e009c5b 100644 --- a/sample/SmartSql.Sample.AspNetCore/Startup.cs +++ b/sample/SmartSql.Sample.AspNetCore/Startup.cs @@ -6,6 +6,8 @@ using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; +using SkyApm.Diagnostics.SmartSql; +using SkyApm.Utilities.DependencyInjection; using SmartSql.Cache.Sync; using SmartSql.ConfigBuilder; using SmartSql.DIExtension; @@ -29,6 +31,7 @@ public Startup(IConfiguration configuration) // This method gets called by the runtime. Use this method to add services to the container. public IServiceProvider ConfigureServices(IServiceCollection services) { + // services.AddSkyApmExtensions().AddSmartSql(); services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2); services .AddSmartSql((sp, builder) => diff --git a/src/SmartSql.Test.Unit/SmartSqlMapConfig.xml b/src/SmartSql.Test.Unit/SmartSqlMapConfig.xml index 0edc3f72..bb0f6cad 100644 --- a/src/SmartSql.Test.Unit/SmartSqlMapConfig.xml +++ b/src/SmartSql.Test.Unit/SmartSqlMapConfig.xml @@ -1,96 +1,99 @@  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/SmartSql.Test/DTO/GetByPageResponse.cs b/src/SmartSql.Test/DTO/GetByPageResponse.cs index f87c31b8..e51b499e 100644 --- a/src/SmartSql.Test/DTO/GetByPageResponse.cs +++ b/src/SmartSql.Test/DTO/GetByPageResponse.cs @@ -8,5 +8,6 @@ public class GetByPageResponse { public IEnumerable List { get; set; } public int Total { get; set; } + public String UserName { get; set; } } -} +} \ No newline at end of file diff --git a/src/SmartSql/Deserializer/TypeDeserializer.cs b/src/SmartSql/Deserializer/TypeDeserializer.cs index 5e728a20..46acb951 100644 --- a/src/SmartSql/Deserializer/TypeDeserializer.cs +++ b/src/SmartSql/Deserializer/TypeDeserializer.cs @@ -1,9 +1,6 @@ using System; -using System.Collections.Generic; using System.Reflection; using System.Reflection.Emit; -using System.Text; -using SmartSql.Configuration; using SmartSql.Reflection.TypeConstants; using SmartSql.Utils; @@ -11,7 +8,8 @@ namespace SmartSql.Deserializer { public class TypeDeserializer { - public static object Deserialize(Type resultType, IDataReaderDeserializer deserializer, ExecutionContext executionContext) + public static object Deserialize(Type resultType, IDataReaderDeserializer deserializer, + ExecutionContext executionContext) { return GetImpl(resultType)(deserializer, executionContext); } @@ -19,17 +17,20 @@ public static object Deserialize(Type resultType, IDataReaderDeserializer deseri private static Func GetImpl(Type resultType) { return CacheUtil> - .GetOrAdd(resultType, CreateImpl); + .GetOrAdd(resultType, CreateImpl); } private static Func CreateImpl(Type resultType) { - var dynamicMethod = new DynamicMethod("CreateGetResult_" + Guid.NewGuid().ToString("N"), CommonType.Object, new[] { IDataReaderDeserializerType.Type, ExecutionContextType.Type }); + var dynamicMethod = new DynamicMethod("CreateGetResult_" + Guid.NewGuid().ToString("N"), CommonType.Object, + new[] {IDataReaderDeserializerType.Type, ExecutionContextType.Type}); var ilGen = dynamicMethod.GetILGenerator(); ilGen.LoadArg(0); ilGen.LoadArg(1); MethodInfo deserMethod; - if (CommonType.IEnumerable.IsAssignableFrom(resultType)) + if ( + CommonType.IEnumerable.IsAssignableFrom(resultType) + && resultType != CommonType.String) { var listItemType = resultType.GenericTypeArguments[0]; deserMethod = IDataReaderDeserializerType.Method.MakeGenericToList(listItemType); @@ -38,13 +39,16 @@ private static Func CreateImp { deserMethod = IDataReaderDeserializerType.Method.MakeGenericToSingle(resultType); } + ilGen.Callvirt(deserMethod); if (resultType.IsValueType) { ilGen.Box(resultType); } + ilGen.Return(); - return (Func)dynamicMethod.CreateDelegate(typeof(Func)); + return (Func) dynamicMethod.CreateDelegate( + typeof(Func)); } } -} +} \ No newline at end of file