mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-08-23 22:11:36 +08:00
Synchronization code
This commit is contained in:
parent
5cf8839b80
commit
5a241248b1
@ -717,7 +717,9 @@ namespace SqlSugar
|
||||
}
|
||||
if (appendColumnsByDataFilter)
|
||||
{
|
||||
var data = ((UpdateableProvider<T>)this.Context.Updateable(new T() { })).UpdateObjs.First();
|
||||
var newData = new T() { };
|
||||
UtilMethods.ClearPublicProperties(newData, this.EntityInfo);
|
||||
var data = ((UpdateableProvider<T>)this.Context.Updateable(newData)).UpdateObjs.First();
|
||||
foreach (var item in this.EntityInfo.Columns.Where(it => !it.IsPrimarykey && !it.IsIgnore && !it.IsOnlyIgnoreUpdate))
|
||||
{
|
||||
var value = item.PropertyInfo.GetValue(data);
|
||||
|
@ -18,6 +18,26 @@ namespace SqlSugar
|
||||
{
|
||||
public class UtilMethods
|
||||
{
|
||||
public static void ClearPublicProperties<T>(T obj,EntityInfo entity)
|
||||
{
|
||||
if (obj == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(obj));
|
||||
}
|
||||
|
||||
Type type = typeof(T);
|
||||
|
||||
foreach (var column in entity.Columns)
|
||||
{
|
||||
if (column.PropertyInfo.CanWrite && column.PropertyInfo.GetSetMethod() != null)
|
||||
{
|
||||
Type propertyType = column.PropertyInfo.PropertyType;
|
||||
object defaultValue = propertyType.IsValueType ? Activator.CreateInstance(propertyType) : null;
|
||||
column.PropertyInfo.SetValue(obj, defaultValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal static Expression GetIncludeExpression(string navMemberName, EntityInfo entityInfo, out Type properyItemType,out bool isList)
|
||||
{
|
||||
var navInfo = entityInfo.Columns.Where(it => it.Navigat != null && it.PropertyName.EqualCase(navMemberName)).FirstOrDefault();
|
||||
|
Loading…
Reference in New Issue
Block a user