## v0.9.16

- 增加 BaseRepository.AttachOnlyPrimary 方法,只附加实体的主键值;
> 在更新前使用可实现不查询数据库再更新、也可以实现更新时不更新值为 null 的字段
```csharp
class T {
    public int id { get; set; }
    public string name { get; set; }
    public string other { get; set; }
}
var item = new T { id = 1, name = "xx" };
fsql.GetRepository<T>().AttachOnlyPrimary(item).Update(item); //只更新 name
```
- 修复 Lambda 表达式中 DateTime.Now.ToString("yyyyMMdd") 不能直接执行的 bug;
This commit is contained in:
28810
2019-09-18 16:58:13 +08:00
parent 52450dc08a
commit 8d92ccd751
24 changed files with 92 additions and 24 deletions

View File

@ -83,7 +83,7 @@ namespace FreeSql.MySql
if (callExp.Method.DeclaringType.IsNumberType()) return "rand()";
break;
case "ToString":
if (callExp.Object != null) return $"cast({getExp(callExp.Object)} as char)";
if (callExp.Object != null) return callExp.Arguments.Count == 0 ? $"cast({getExp(callExp.Object)} as char)" : null;
break;
}
@ -385,7 +385,7 @@ namespace FreeSql.MySql
break;
case "Equals": return $"({left} = {getExp(exp.Arguments[0])})";
case "CompareTo": return $"timestampdiff(microsecond,{args1},{left})";
case "ToString": return $"date_format({left}, '%Y-%m-%d %H:%i:%s.%f')";
case "ToString": return exp.Arguments.Count == 0 ? $"date_format({left}, '%Y-%m-%d %H:%i:%s.%f')" : null;
}
}
return null;