mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-10-15 18:55:07 +08:00
Synchronization code
This commit is contained in:
@@ -717,7 +717,9 @@ namespace SqlSugar
|
|||||||
}
|
}
|
||||||
if (appendColumnsByDataFilter)
|
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))
|
foreach (var item in this.EntityInfo.Columns.Where(it => !it.IsPrimarykey && !it.IsIgnore && !it.IsOnlyIgnoreUpdate))
|
||||||
{
|
{
|
||||||
var value = item.PropertyInfo.GetValue(data);
|
var value = item.PropertyInfo.GetValue(data);
|
||||||
|
@@ -18,6 +18,26 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
public class UtilMethods
|
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)
|
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();
|
var navInfo = entityInfo.Columns.Where(it => it.Navigat != null && it.PropertyName.EqualCase(navMemberName)).FirstOrDefault();
|
||||||
|
Reference in New Issue
Block a user