Browse Source

Add db.UpdateableByObject(o).ExecuteCommandAsync()

pull/31/head
sunkaixuan 2 years ago
parent
commit
02d3400cd6
  1. 2
      Src/Asp.Net/SqlServerTest/Demo/Demo2_Updateable.cs
  2. 2
      Src/Asp.Net/SqlServerTest/Demo/Demo3_Insertable.cs
  3. 9
      Src/Asp.Net/SqlSugar/Abstract/UpdateProvider/UpdateMethodInfo.cs

2
Src/Asp.Net/SqlServerTest/Demo/Demo2_Updateable.cs

@ -136,7 +136,7 @@ namespace OrmTest
object o = db.Queryable<Order>().First();
db.UpdateableByObject(o).ExecuteCommand();
db.UpdateableByObject(o).ExecuteCommandAsync().GetAwaiter().GetResult();
object os = db.Queryable<Order>().Take(2).ToList();
db.UpdateableByObject(os).ExecuteCommand();
Console.WriteLine("#### Updateable End ####");

2
Src/Asp.Net/SqlServerTest/Demo/Demo3_Insertable.cs

@ -86,7 +86,7 @@ namespace OrmTest
int result2 = db.Fastest<System.Data.DataTable>().AS("order").BulkCopy( dataTable);
object o = db.Queryable<Order>().First();
db.InsertableByObject(o).ExecuteCommand();
db.InsertableByObject(o).ExecuteCommandAsync().GetAwaiter().GetResult();
object os = db.Queryable<Order>().Take(2).ToList();
db.InsertableByObject(os).ExecuteCommand();

9
Src/Asp.Net/SqlSugar/Abstract/UpdateProvider/UpdateMethodInfo.cs

@ -3,6 +3,7 @@ using System.Collections;
using System.Collections.Generic;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
namespace SqlSugar
{
@ -19,5 +20,13 @@ namespace SqlSugar
var result= inertable.GetType().GetMethod("ExecuteCommand").Invoke(inertable,new object[] { });
return (int)result;
}
public async Task<int> ExecuteCommandAsync()
{
if (Context == null) return 0;
var inertable = MethodInfo.Invoke(Context, new object[] { objectValue });
var result = inertable.GetType().GetMethod("ExecuteCommandAsync").Invoke(inertable, new object[] { });
return await (Task<int>)result;
}
}
}

Loading…
Cancel
Save