Skip to content

Commit

Permalink
[fix]修正CsvDb.Set在没有数据时无法新增的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
nnhy committed Aug 28, 2024
1 parent bf9d150 commit 06a30af
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions NewLife.Core/IO/CsvDb.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public void Write(IEnumerable<T> models, Boolean append)

/// <summary>尾部插入数据,性能极好</summary>
/// <param name="model"></param>
public void Add(T model) => Add(new[] { model });
public void Add(T model) => Add([model]);

/// <summary>尾部插入数据,性能极好</summary>
/// <param name="models"></param>
Expand All @@ -79,7 +79,7 @@ public void Write(IEnumerable<T> models, Boolean append)
/// <summary>删除数据,性能很差,全部读取剔除后保存</summary>
/// <param name="model"></param>
/// <returns></returns>
public Int32 Remove(T model) => Remove(new[] { model });
public Int32 Remove(T model) => Remove([model]);

/// <summary>删除数据,性能很差,全部读取剔除后保存</summary>
/// <param name="models"></param>
Expand Down Expand Up @@ -119,7 +119,7 @@ public Int32 Remove(Func<T, Boolean> predicate)
}

/// <summary>清空数据。只写头部</summary>
public void Clear() => Write(new T[0], false);
public void Clear() => Write([], false);

/// <summary>更新指定数据行,性能很差,全部读取替换后保存</summary>
/// <param name="model"></param>
Expand All @@ -138,7 +138,7 @@ private Boolean Set(T model, Boolean add)
lock (this)
{
var list = FindAll();
if (list.Count == 0) return false;
if (!add && list.Count == 0) return false;

// 找到目标数据行,并替换
var flag = false;
Expand Down

0 comments on commit 06a30af

Please sign in to comment.