mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-08-23 22:11:36 +08:00
fix error when StorageableByObject(null) or StorageableByObject(new List<xx>())
This commit is contained in:
parent
cbb7a670c6
commit
21198be833
@ -111,9 +111,9 @@ namespace SqlSugar
|
|||||||
}
|
}
|
||||||
public StorageableCommonMethodInfo IgnoreColumns(params string[] ignoreColumns)
|
public StorageableCommonMethodInfo IgnoreColumns(params string[] ignoreColumns)
|
||||||
{
|
{
|
||||||
PropertyInfo property = ObjectValue.GetType().GetProperty(type);
|
PropertyInfo property = ObjectValue?.GetType().GetProperty(type);
|
||||||
var value = property.GetValue(ObjectValue);
|
var value = property?.GetValue(ObjectValue);
|
||||||
var newObj = value.GetType().GetMyMethod("IgnoreColumns", 1, typeof(string[])).Invoke(value, new object[] { ignoreColumns });
|
var newObj = value?.GetType().GetMyMethod("IgnoreColumns", 1, typeof(string[])).Invoke(value, new object[] { ignoreColumns });
|
||||||
StorageableCommonMethodInfo result = new StorageableCommonMethodInfo();
|
StorageableCommonMethodInfo result = new StorageableCommonMethodInfo();
|
||||||
result.Value = newObj;
|
result.Value = newObj;
|
||||||
return result;
|
return result;
|
||||||
@ -124,6 +124,7 @@ namespace SqlSugar
|
|||||||
public object Value { get; set; }
|
public object Value { get; set; }
|
||||||
public int ExecuteCommand()
|
public int ExecuteCommand()
|
||||||
{
|
{
|
||||||
|
if(Value == null) return 0;
|
||||||
var newObj = Value.GetType().GetMethod("ExecuteCommand").Invoke(Value, new object[] { });
|
var newObj = Value.GetType().GetMethod("ExecuteCommand").Invoke(Value, new object[] { });
|
||||||
return (int)newObj;
|
return (int)newObj;
|
||||||
}
|
}
|
||||||
|
@ -54,6 +54,9 @@ namespace OrmTest
|
|||||||
var result7 = db.Updateable(updateObj)
|
var result7 = db.Updateable(updateObj)
|
||||||
.IgnoreColumns(ignoreAllNullColumns: true, ignoreAllDefaultValue: true)
|
.IgnoreColumns(ignoreAllNullColumns: true, ignoreAllDefaultValue: true)
|
||||||
.ExecuteCommand();
|
.ExecuteCommand();
|
||||||
|
var result7a = db.StorageableByObject(new List<StudentWithSnowflake>()).ToStorage().AsUpdateable
|
||||||
|
.IgnoreColumns(new[] { "" })
|
||||||
|
.ExecuteCommand();
|
||||||
|
|
||||||
// 使用最快的方式批量更新实体对象列表(Bulk update a list of entity objects using the fastest method)
|
// 使用最快的方式批量更新实体对象列表(Bulk update a list of entity objects using the fastest method)
|
||||||
var result8 = db.Fastest<StudentWithSnowflake>().BulkUpdate(updateObjs);
|
var result8 = db.Fastest<StudentWithSnowflake>().BulkUpdate(updateObjs);
|
||||||
|
Loading…
Reference in New Issue
Block a user