Update db.InsertByObject

This commit is contained in:
sunkaixuan 2023-06-03 19:32:01 +08:00
parent 90aff49603
commit 067b200e6c
2 changed files with 20 additions and 0 deletions

View File

@ -12,6 +12,7 @@ namespace SqlSugar
internal SqlSugarProvider Context { get; set; }
internal MethodInfo MethodInfo { get; set; }
internal object objectValue { get; set; }
internal string[] ignoreColumns { get; set; }
public int ExecuteCommand()
{
@ -41,6 +42,18 @@ namespace SqlSugar
var result = inertable.GetType().GetMyMethod("ExecuteReturnIdentityAsync",0).Invoke(inertable, new object[] { });
return await (Task<int>)result;
}
public CommonMethodInfo IgnoreColumns(params string [] ignoreColumns)
{
var inertable = MethodInfo.Invoke(Context, new object[] { objectValue });
var newMethod = inertable.GetType().GetMyMethod("IgnoreColumns", 1, typeof(string[]));
var result = newMethod.Invoke(inertable, new object[] { ignoreColumns });
return new CommonMethodInfo()
{
Context = result
};
}
public CommonMethodInfo SplitTable()
{
var inertable = MethodInfo.Invoke(Context, new object[] { objectValue });

View File

@ -25,6 +25,13 @@ namespace SqlSugar
{
return type.GetMethods().FirstOrDefault(it => it.Name == name && it.GetParameters().Length == argCount);
}
public static MethodInfo GetMyMethod(this Type type, string name, int argCount,Type parameterType)
{
return type.GetMethods().FirstOrDefault(it =>
it.Name == name &&
it.GetParameters().Length == argCount&&
it.GetParameters().First().ParameterType==parameterType);
}
public static List<T> ToList<T>(this T thisValue,Func<T,T> action) where T:class,new()
{
return new List<T> { thisValue };