mirror of
https://github.com/nsnail/FreeSql.git
synced 2025-09-21 02:42:41 +08:00
## 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:
@@ -140,6 +140,11 @@ namespace FreeSql
|
||||
|
||||
public void Attach(TEntity data) => _db.Attach(data);
|
||||
public void Attach(IEnumerable<TEntity> data) => _db.AttachRange(data);
|
||||
public IBasicRepository<TEntity> AttachOnlyPrimary(TEntity data)
|
||||
{
|
||||
_db.AttachOnlyPrimary(data);
|
||||
return this;
|
||||
}
|
||||
public void FlushState() => _dbset.FlushState();
|
||||
|
||||
public TEntity InsertOrUpdate(TEntity entity)
|
||||
|
Reference in New Issue
Block a user