Update Db.InsertableByObject

This commit is contained in:
sunkaixuan 2023-06-03 19:49:39 +08:00
parent 1e2447fadb
commit 5a208ea9d9
3 changed files with 40 additions and 6 deletions

View File

@ -35,5 +35,39 @@ namespace SqlSugar
return await (Task<int>)result; return await (Task<int>)result;
} }
} }
public class SplitMethodInfo
{
internal object Context { get; set; }
public int ExecuteCommand()
{
if (Context == null) return 0;
var result = Context.GetType().GetMyMethod("ExecuteCommand", 0).Invoke(Context, new object[] { });
return (int)result;
}
public async Task<int> ExecuteCommandAsync()
{
if (Context == null) return 0;
var result = Context.GetType().GetMyMethod("ExecuteCommandAsync", 0).Invoke(Context, new object[] { });
return await (Task<int>)result;
}
}
public class UpdateCommonMethodInfo
{
internal object Context { get; set; }
public int ExecuteCommand()
{
if (Context == null) return 0;
var result = Context.GetType().GetMyMethod("ExecuteCommand", 0).Invoke(Context, new object[] { });
return (int)result;
}
public async Task<int> ExecuteCommandAsync()
{
if (Context == null) return 0;
var result = Context.GetType().GetMyMethod("ExecuteCommandAsync", 0).Invoke(Context, new object[] { });
return await (Task<int>)result;
}
}
} }

View File

@ -54,12 +54,12 @@ namespace SqlSugar
}; };
} }
public CommonMethodInfo SplitTable() public SplitMethodInfo SplitTable()
{ {
var inertable = MethodInfo.Invoke(Context, new object[] { objectValue }); var inertable = MethodInfo.Invoke(Context, new object[] { objectValue });
var newMethod = inertable.GetType().GetMyMethod("SplitTable", 0); var newMethod = inertable.GetType().GetMyMethod("SplitTable", 0);
var result = newMethod.Invoke(inertable, new object[] { }); var result = newMethod.Invoke(inertable, new object[] { });
return new CommonMethodInfo() return new SplitMethodInfo()
{ {
Context = result Context = result
}; };

View File

@ -29,22 +29,22 @@ namespace SqlSugar
var result = inertable.GetType().GetMyMethod("ExecuteCommandAsync",0).Invoke(inertable, new object[] { }); var result = inertable.GetType().GetMyMethod("ExecuteCommandAsync",0).Invoke(inertable, new object[] { });
return await (Task<int>)result; return await (Task<int>)result;
} }
public CommonMethodInfo IgnoreColumns(params string[] ignoreColumns) public UpdateCommonMethodInfo IgnoreColumns(params string[] ignoreColumns)
{ {
var inertable = MethodInfo.Invoke(Context, new object[] { objectValue }); var inertable = MethodInfo.Invoke(Context, new object[] { objectValue });
var newMethod = inertable.GetType().GetMyMethod("IgnoreColumns", 1,typeof(string[])); var newMethod = inertable.GetType().GetMyMethod("IgnoreColumns", 1,typeof(string[]));
var result = newMethod.Invoke(inertable, new object[] { ignoreColumns }); var result = newMethod.Invoke(inertable, new object[] { ignoreColumns });
return new CommonMethodInfo() return new UpdateCommonMethodInfo()
{ {
Context = result Context = result
}; };
} }
public CommonMethodInfo SplitTable() public UpdateCommonMethodInfo SplitTable()
{ {
var inertable = MethodInfo.Invoke(Context, new object[] { objectValue }); var inertable = MethodInfo.Invoke(Context, new object[] { objectValue });
var newMethod = inertable.GetType().GetMyMethod("SplitTable", 0); var newMethod = inertable.GetType().GetMyMethod("SplitTable", 0);
var result = newMethod.Invoke(inertable, new object[] { }); var result = newMethod.Invoke(inertable, new object[] { });
return new CommonMethodInfo() return new UpdateCommonMethodInfo()
{ {
Context = result Context = result
}; };