While you call the UpdateNonDefaults method, it generates sql through the ToUpdateStatement method in SqlExpression.cs
public virtual string ToUpdateStatement(T item, bool excludeDefaults = false) { var setFields = new StringBuilder(); foreach (var fieldDef in modelDef.FieldDefinitions) { if (fieldDef.ShouldSkipUpdate()) continue; if (fieldDef.IsRowVersion) continue; if (updateFields.Count > 0 && !updateFields.Contains(fieldDef.Name)) continue;
Pay attention to the line:
if (excludeDefaults && (value == null || value.Equals(value.GetType().GetDefaultValue()))) continue;
When you update a value with a boolean value from true to false, here the value is fasle , and value.GetType () is actually typeof (bool) , not typeof (bool?) , So value.GetType (). GetDefaultValue () is always false. Then this column is ignored ...
Kevin source share