mirror of
				https://github.com/nsnail/FreeSql.git
				synced 2025-11-04 09:15:27 +08:00 
			
		
		
		
	补充 开放 IUpdate UpdateColumns 方法功能;
现实更新实体时,只更新指定的列(与 IgnoreColumns 对应);
This commit is contained in:
		@@ -264,11 +264,28 @@ namespace FreeSql.Internal.CommonProvider {
 | 
			
		||||
			foreach (var col in cols) _ignore.Add(col, true);
 | 
			
		||||
			return this;
 | 
			
		||||
		}
 | 
			
		||||
		public IUpdate<T1> UpdateColumns(Expression<Func<T1, object>> 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<T1> IgnoreColumns(string[] columns) {
 | 
			
		||||
			_ignore.Clear();
 | 
			
		||||
			foreach (var col in columns) _ignore.Add(col, true);
 | 
			
		||||
			return this;
 | 
			
		||||
		}
 | 
			
		||||
		public IUpdate<T1> UpdateColumns(string[] columns) {
 | 
			
		||||
			var cols = columns.ToDictionary(a => a);
 | 
			
		||||
			_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<T1> SetSource(T1 source) => this.SetSource(new[] { source });
 | 
			
		||||
		public IUpdate<T1> SetSource(IEnumerable<T1> source) {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user