using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MJTop.Data
{
///
/// 排除列
///
public class ExcludeColumn
{
///
/// 表列集合
///
internal NameValueCollection Coll { get; set; }
private DB Db { get; set; }
internal ExcludeColumn(DB db)
{
this.Db = db;
this.Coll = new NameValueCollection();
}
///
/// 需排除的 表名与多个列名
///
/// 表名
/// 一个或多个列名
public void Add(string tableName, params string[] columnNames)
{
Db.CheckTabStuct(tableName, columnNames);
if (columnNames != null && columnNames.Length > 0)
{
foreach (var columnName in columnNames)
{
this.Coll.Add(tableName, columnName);
}
}
}
///
/// 需排除的 表名与列名集合
///
/// 表列集合
public void AddRange(NameValueCollection tableColumns)
{
if (tableColumns == null)
{
foreach (var tableName in tableColumns.AllKeys)
{
string[] columnNames;
if (tableColumns.TryGetValues(tableName, out columnNames))
{
Db.CheckTabStuct(tableName, columnNames);
foreach (var columnName in columnNames)
{
this.Coll.Add(tableName, columnName);
}
}
}
}
}
///
/// 清空排除项
///
public void Clear()
{
this.Coll.Clear();
}
///
/// 删除对应表的 排除项
///
/// 表名
public void Remove(string tableName)
{
Db.CheckTabStuct(tableName);
this.Coll.Remove(tableName);
}
///
/// 删除指定的排除项
///
/// 表名
/// 列名
/// 返回bool
public bool Remove(string tableName,string columnName)
{
Db.CheckTabStuct(tableName, columnName);
return this.Coll.Remove(tableName, columnName);
}
}
}