mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-06-28 13:34:32 +08:00
Add attribute propertty IsOnlyIgnoreUpdate
This commit is contained in:
parent
19ab13134a
commit
c2c1a013d5
@ -38,6 +38,20 @@ namespace OrmTest
|
||||
Dc=it.Int
|
||||
}).ToSql().Key;
|
||||
UValidate.Check(sql, "SELECT [Dc] AS [DcNull] , [Int] AS [Dc] FROM [UnitSelectTest]", "Queryable");
|
||||
|
||||
sql= Db.Updateable<UnitSelectTest2>(new UnitSelectTest2()).ToSql().Key;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public class UnitSelectTest2
|
||||
{
|
||||
[SqlSugar.SugarColumn(IsOnlyIgnoreUpdate = true)]
|
||||
public decimal? DcNull { get; set; }
|
||||
public decimal Dc { get; set; }
|
||||
public int? IntNull { get; set; }
|
||||
[SqlSugar.SugarColumn(IsPrimaryKey = true)]
|
||||
public decimal Int { get; set; }
|
||||
}
|
||||
|
||||
public class UnitSelectTest
|
||||
|
@ -10,7 +10,7 @@ namespace OrmTest
|
||||
{
|
||||
public static void Check(object a, object b, object name)
|
||||
{
|
||||
if (a?.ToString() != b?.ToString())
|
||||
if (a?.ToString()?.Trim() != b?.ToString()?.Trim())
|
||||
{
|
||||
throw new Exception(name + " error");
|
||||
}
|
||||
|
@ -173,6 +173,7 @@ namespace SqlSugar
|
||||
column.NoSerialize = sugarColumn.NoSerialize;
|
||||
column.DefaultValue = sugarColumn.DefaultValue;
|
||||
column.IndexGroupNameList = sugarColumn.IndexGroupNameList;
|
||||
column.IsOnlyIgnoreUpdate = sugarColumn.IsOnlyIgnoreUpdate;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -291,6 +291,11 @@ namespace SqlSugar
|
||||
sqlBuilder.UpdateBuilder.LambdaExpressions = InstanceFactory.GetLambdaExpressions(this.CurrentConnectionConfig);
|
||||
sqlBuilder.Context = result.SqlBuilder.UpdateBuilder.Context = this;
|
||||
result.Init();
|
||||
var ignoreColumns = result.EntityInfo.Columns.Where(it => it.IsOnlyIgnoreUpdate).ToList();
|
||||
if (ignoreColumns!=null&&ignoreColumns.Any())
|
||||
{
|
||||
result = (UpdateableProvider<T>)result.IgnoreColumns(ignoreColumns.Select(it=>it.PropertyName).ToArray());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -27,6 +27,7 @@ namespace SqlSugar
|
||||
public int DecimalDigits { get; set; }
|
||||
public string OracleSequenceName { get; set; }
|
||||
public bool IsOnlyIgnoreInsert { get; set; }
|
||||
public bool IsOnlyIgnoreUpdate { get; set; }
|
||||
public bool IsTranscoding { get; set; }
|
||||
public string SerializeDateTimeFormat { get; set; }
|
||||
public bool IsJson { get; set; }
|
||||
|
@ -112,6 +112,13 @@ namespace SqlSugar
|
||||
set { _IsOnlyIgnoreInsert = value; }
|
||||
}
|
||||
|
||||
private bool _IsOnlyIgnoreUpdate;
|
||||
public bool IsOnlyIgnoreUpdate
|
||||
{
|
||||
get { return _IsOnlyIgnoreUpdate; }
|
||||
set { _IsOnlyIgnoreUpdate = value; }
|
||||
}
|
||||
|
||||
|
||||
private bool _IsEnableUpdateVersionValidation;
|
||||
public bool IsEnableUpdateVersionValidation {
|
||||
|
Loading…
Reference in New Issue
Block a user