diff --git a/Src/Asp.NetCore2/SqlSeverTest/Program.cs b/Src/Asp.NetCore2/SqlSeverTest/Program.cs index 4c56d56e2..9186af82b 100644 --- a/Src/Asp.NetCore2/SqlSeverTest/Program.cs +++ b/Src/Asp.NetCore2/SqlSeverTest/Program.cs @@ -7,7 +7,8 @@ namespace OrmTest public class Program { static void Main(string[] args) - { + { + UnitStringToExp.Init(); //Each example will automatically create a table and can run independently. //每个例子都会自动建表 并且可以独立运行 _1_CodeFirst.Init(); diff --git a/Src/Asp.NetCore2/SqlSeverTest/UserTestCases/UnitTest/UnitStringToExp.cs b/Src/Asp.NetCore2/SqlSeverTest/UserTestCases/UnitTest/UnitStringToExp.cs index 4540fb3c8..2331cddb2 100644 --- a/Src/Asp.NetCore2/SqlSeverTest/UserTestCases/UnitTest/UnitStringToExp.cs +++ b/Src/Asp.NetCore2/SqlSeverTest/UserTestCases/UnitTest/UnitStringToExp.cs @@ -56,6 +56,15 @@ namespace OrmTest " it.Name as Name" } , 10) .ToListAsync().GetAwaiter().GetResult(); + + var userInfo5 = db.Queryable() + .Select("it", + new List() + { "it.Id as userId", + " {0} as id", + " it.Name as Name" } + , 10) + .InSingleAsync(1).GetAwaiter().GetResult(); } private static void Test03() diff --git a/Src/Asp.NetCore2/SqlSugar/Abstract/DeleteProvider/DeleteNavMethodInfo.cs b/Src/Asp.NetCore2/SqlSugar/Abstract/DeleteProvider/DeleteNavMethodInfo.cs index eb8989421..9e4611321 100644 --- a/Src/Asp.NetCore2/SqlSugar/Abstract/DeleteProvider/DeleteNavMethodInfo.cs +++ b/Src/Asp.NetCore2/SqlSugar/Abstract/DeleteProvider/DeleteNavMethodInfo.cs @@ -11,7 +11,7 @@ namespace SqlSugar internal object MethodInfos { get; set; } internal SqlSugarProvider Context { get; set; } - public DeleteNavMethodInfo IncludeByNameString(string navMemberName, DeleteNavOptions updateNavOptions = null) + public DeleteNavMethodInfo IncludeByNameString(string navMemberName, DeleteNavOptions deleteNavOptions = null) { var type = MethodInfos.GetType().GetGenericArguments()[0]; var entityInfo = this.Context.EntityMaintenance.GetEntityInfo(type); @@ -20,11 +20,11 @@ namespace SqlSugar Expression exp = UtilMethods.GetIncludeExpression(navMemberName, entityInfo, out properyItemType, out isList); var method = this.MethodInfos.GetType().GetMyMethod("Include", 2, isList) .MakeGenericMethod(properyItemType); - var obj = method.Invoke(this.MethodInfos, new object[] { exp, updateNavOptions }); + var obj = method.Invoke(this.MethodInfos, new object[] { exp, deleteNavOptions }); this.MethodInfos = obj; return this; } - public DeleteNavMethodInfo ThenIncludeByNameString(string navMemberName, DeleteNavOptions updateNavOptions = null) + public DeleteNavMethodInfo ThenIncludeByNameString(string navMemberName, DeleteNavOptions deleteNavOptions = null) { var type = MethodInfos.GetType().GetGenericArguments()[1]; var entityInfo = this.Context.EntityMaintenance.GetEntityInfo(type); @@ -33,7 +33,7 @@ namespace SqlSugar Expression exp = UtilMethods.GetIncludeExpression(navMemberName, entityInfo, out properyItemType, out isList); var method = this.MethodInfos.GetType().GetMyMethod("ThenInclude", 2, isList) .MakeGenericMethod(properyItemType); - var obj = method.Invoke(this.MethodInfos, new object[] { exp, updateNavOptions }); + var obj = method.Invoke(this.MethodInfos, new object[] { exp, deleteNavOptions }); this.MethodInfos = obj; return this; } diff --git a/Src/Asp.NetCore2/SqlSugar/Entities/DynamicSelectModel.cs b/Src/Asp.NetCore2/SqlSugar/Entities/DynamicSelectModel.cs index 2603f727c..ac47b7ba4 100644 --- a/Src/Asp.NetCore2/SqlSugar/Entities/DynamicSelectModel.cs +++ b/Src/Asp.NetCore2/SqlSugar/Entities/DynamicSelectModel.cs @@ -10,6 +10,39 @@ namespace SqlSugar public class DynamicCoreSelectModel { public object Value { get; set; } + public object InSingle(object value) + { + if (Value is null) + { + throw new InvalidOperationException("Value cannot be null."); + } + + var method = Value.GetType().GetMyMethod("InSingle", 1); + if (method == null) + { + throw new InvalidOperationException("The Value object does not have an InSingle method with one parameter."); + } + + return method.Invoke(Value, new object[] { value }); + } + + public async Task InSingleAsync(object value) + { + if (Value is null) + { + throw new InvalidOperationException("Value cannot be null."); + } + + var method = Value.GetType().GetMyMethod("InSingleAsync", 1); + if (method == null) + { + throw new InvalidOperationException("The Value object does not have an InSingleAsync method with one parameter."); + } + + var task = (Task)method.Invoke(Value, new object[] { value }); + return await GetTask(task).ConfigureAwait(false); + } + public object ToList() {