From 5acf0b9eb4bfbc4305e8494be44fc3d311d2bc5d Mon Sep 17 00:00:00 2001
From: 28810 <28810@YEXIANGQIN>
Date: Mon, 23 Sep 2019 21:58:30 +0800
Subject: [PATCH] =?UTF-8?q?-=20=E4=BC=98=E5=8C=96=20IUpdate.IgnoreColumns/?=
=?UTF-8?q?UpdateColumns=20=E5=8F=AF=E5=AF=B9=E5=B1=9E=E6=80=A7=E5=90=8D?=
=?UTF-8?q?=EF=BC=8C=E6=88=96=E5=AD=97=E6=AE=B5=E5=90=8D=E5=81=9A=E8=AE=BE?=
=?UTF-8?q?=E7=BD=AE=EF=BC=9B#95?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
FreeSql/FreeSql.xml | 4 +--
FreeSql/Interface/Curd/IUpdate.cs | 4 +--
.../Internal/CommonProvider/UpdateProvider.cs | 25 ++++++-------------
3 files changed, 11 insertions(+), 22 deletions(-)
diff --git a/FreeSql/FreeSql.xml b/FreeSql/FreeSql.xml
index f52a399d..6ba2f4df 100644
--- a/FreeSql/FreeSql.xml
+++ b/FreeSql/FreeSql.xml
@@ -1616,7 +1616,7 @@
忽略的列
-
+ 属性名,或者字段名
@@ -1630,7 +1630,7 @@
指定的列
-
+ 属性名,或者字段名
diff --git a/FreeSql/Interface/Curd/IUpdate.cs b/FreeSql/Interface/Curd/IUpdate.cs
index 26f11dd8..857b6169 100644
--- a/FreeSql/Interface/Curd/IUpdate.cs
+++ b/FreeSql/Interface/Curd/IUpdate.cs
@@ -49,7 +49,7 @@ namespace FreeSql
///
/// 忽略的列
///
- ///
+ /// 属性名,或者字段名
///
IUpdate IgnoreColumns(string[] columns);
@@ -62,7 +62,7 @@ namespace FreeSql
///
/// 指定的列
///
- ///
+ /// 属性名,或者字段名
///
IUpdate UpdateColumns(string[] columns);
diff --git a/FreeSql/Internal/CommonProvider/UpdateProvider.cs b/FreeSql/Internal/CommonProvider/UpdateProvider.cs
index a4866392..e29c443a 100644
--- a/FreeSql/Internal/CommonProvider/UpdateProvider.cs
+++ b/FreeSql/Internal/CommonProvider/UpdateProvider.cs
@@ -368,27 +368,16 @@ namespace FreeSql.Internal.CommonProvider
public abstract List ExecuteUpdated();
public abstract Task> ExecuteUpdatedAsync();
- public IUpdate IgnoreColumns(Expression> columns)
- {
- var cols = _commonExpression.ExpressionSelectColumns_MemberAccess_New_NewArrayInit(null, columns?.Body, false, null).Distinct();
- _ignore.Clear();
- foreach (var col in cols) _ignore.Add(col, true);
- return this;
- }
- public IUpdate UpdateColumns(Expression> columns)
- {
- var cols = _commonExpression.ExpressionSelectColumns_MemberAccess_New_NewArrayInit(null, columns?.Body, false, null).ToDictionary(a => a, a => true);
- _ignore.Clear();
- foreach (var col in _table.Columns.Values)
- if (cols.ContainsKey(col.Attribute.Name) == false)
- _ignore.Add(col.Attribute.Name, true);
- return this;
- }
+ public IUpdate IgnoreColumns(Expression> columns) => IgnoreColumns(_commonExpression.ExpressionSelectColumns_MemberAccess_New_NewArrayInit(null, columns?.Body, false, null));
+ public IUpdate UpdateColumns(Expression> columns) => UpdateColumns(_commonExpression.ExpressionSelectColumns_MemberAccess_New_NewArrayInit(null, columns?.Body, false, null));
public IUpdate IgnoreColumns(string[] columns)
{
+ var cols = columns.ToDictionary(a => a);
_ignore.Clear();
- foreach (var col in columns) _ignore.Add(col, true);
+ foreach (var col in _table.Columns.Values)
+ if (cols.ContainsKey(col.Attribute.Name) == true || cols.ContainsKey(col.CsName) == true)
+ _ignore.Add(col.Attribute.Name, true);
return this;
}
public IUpdate UpdateColumns(string[] columns)
@@ -396,7 +385,7 @@ namespace FreeSql.Internal.CommonProvider
var cols = columns.ToDictionary(a => a);
_ignore.Clear();
foreach (var col in _table.Columns.Values)
- if (cols.ContainsKey(col.Attribute.Name) == false)
+ if (cols.ContainsKey(col.Attribute.Name) == false && cols.ContainsKey(col.CsName) == false)
_ignore.Add(col.Attribute.Name, true);
return this;
}