Skip to content

Commit

Permalink
391:MDataTable 增加 GetIndex 方法(统计满足条件的行所在的索引)(2016-10-16)
Browse files Browse the repository at this point in the history
392:NoSqlAction 文本数据库修正无法删除最后1条数据的问题(2016-10-16)
  • Loading branch information
cyq1162 committed Oct 16, 2016
1 parent 5eb8785 commit 35ee917
Show file tree
Hide file tree
Showing 8 changed files with 60 additions and 15 deletions.
19 changes: 9 additions & 10 deletions Action/NoSqlAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,15 @@ private MDataTable Table
}
else if (_tableList.ContainsKey(_FileFullName))
{
_Table = _tableList[_FileFullName];
if (_Table.Rows.Count == 0)
{
_tableList.Remove(_FileFullName);
}
else
{
return _Table;
}
return _tableList[_FileFullName];
//if (_Table.Rows.Count == 0)
//{
// _tableList.Remove(_FileFullName);// 会引发最后一条数据无法删除的问题。
//}
//else
//{
// return _Table;
//}
}

switch (_DalType)
Expand Down Expand Up @@ -392,7 +392,6 @@ public bool Fill(object where)
MDataRow row = Table.FindRow(where);
if (row != null)
{

_Row.LoadFrom(row);
_Row.SetState(0);//查询时,后续会定位状态为1
return true;
Expand Down
2 changes: 1 addition & 1 deletion DAL/NoSql/NoSqlCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ void FormatSqlText(string sqlText)
{
string[] fields = fieldText.ToString().Split(',');
fieldItems.AddRange(fields);
fieldText = null;
fieldText.Length = 0;
}
#endregion
}
Expand Down
6 changes: 3 additions & 3 deletions Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
[assembly: AssemblyTitle("CYQ.Data 数据层(ORM)框架 V5 版本")]
[assembly: AssemblyDescription("论坛:http://www.cyqdata.com/cyqdata")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("秋式软件 (2016-10-14)")]
[assembly: AssemblyCompany("秋式软件 (2016-10-16)")]
[assembly: AssemblyProduct("CYQ.Data 数据层(ORM)框架 V5 版本")]
[assembly: AssemblyCopyright("版权所有 (C) 秋式软件 2010-2020")]
[assembly: AssemblyTrademark("CYQ.Data")]
Expand All @@ -31,5 +31,5 @@
//
// 可以指定所有这些值,也可以使用“修订号”和“内部版本号”的默认值,
// 方法是按如下所示使用“*”:
[assembly: AssemblyVersion("5.6.6.5")]
[assembly: AssemblyFileVersion("5.6.6.5")]
[assembly: AssemblyVersion("5.6.6.6")]
[assembly: AssemblyFileVersion("5.6.6.6")]
1 change: 1 addition & 0 deletions Table/MDataCell.cs
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@ public MCellStruct Clone()
ms.Description = Description;
ms.MDataColumn = MDataColumn;
ms.AlterOp = AlterOp;
ms.TableName = TableName;
return ms;
}
#endregion
Expand Down
11 changes: 11 additions & 0 deletions Table/MDataRowCollection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,17 @@ private void CheckError(MDataRow item, IEnumerable<MDataRow> collection)

#endregion

//public void Remove(MDataRow row)
//{
// if (this.Count == 1 && row == this[0])
// {
// this.Clear();
// }
// else
// {
// base.Remove(row);
// }
//}
}
/// <summary>
/// 实现Winform DataGridView 的添加编辑和删除操作功能。
Expand Down
7 changes: 7 additions & 0 deletions Table/MDataTable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,13 @@ public List<MDataRow> FindAll(object where)
return MDataTableFilter.FindAll(this, where);
}
/// <summary>
/// 统计满足条件的行所在的索引
/// </summary>
public int GetIndex(object where)
{
return MDataTableFilter.GetIndex(this, where);
}
/// <summary>
/// 统计满足条件的行数
/// </summary>
public int GetCount(object where)
Expand Down
25 changes: 25 additions & 0 deletions Table/MDataTableFilter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,31 @@ public static MDataTable[] Split(MDataTable table, object whereObj)
}
return mdt2;
}
public static int GetIndex(MDataTable table, object whereObj)
{
int index = -1;
if (table.Rows.Count > 0)
{
if (Convert.ToString(whereObj).Trim() == "")
{
return 0;
}
TFilter[] filters = GetTFilter(whereObj, table.Columns);
if (filters.Length > 0)
{
for (int i = 0; i < table.Rows.Count; i++)
{
if (CompareMore(table.Rows[i], filters))
{
index = i;
break;
}
}
}
filters = null;
}
return index;
}
public static int GetCount(MDataTable table, object whereObj)
{
int count = 0;
Expand Down
4 changes: 3 additions & 1 deletion 更新记录.txt
Original file line number Diff line number Diff line change
Expand Up @@ -603,4 +603,6 @@
387��MDataTable ToJson ����null�����ݣ�Ĭ����� xx:null ֵ��2016-10-09)
388��Oracle(DBTool.GetTables) ���Ӷ���ͼ�Ĺ��ˣ�2016-10-10)
389��JsonHelper ����ʵ��Ƕ�׵����⡢ͬʱ���Ӷ������֧�֣�2016-10-14)
390��MDataTable AcceptChange ����������ʱ�ĵ��������£�2016-10-14)
390��MDataTable AcceptChange ����������ʱ�ĵ��������£�2016-10-14)
391��MDataTable ���� GetIndex ������ͳ�����������������ڵ���������2016-10-16)
392��NoSqlAction �ı����ݿ������޷�ɾ�����1�����ݵ����⣨2016-10-16)

0 comments on commit 35ee917

Please sign in to comment.