using System.Data;
using System.Linq;
namespace Terminal.Gui {
///
/// implementation that wraps
/// a . This class is
/// mutable: changes are permitted to the wrapped .
///
public class DataTableSource : ITableSource
{
///
/// The data table this source wraps.
///
public DataTable DataTable { get; private set; }
///
/// Creates a new instance based on the data in .
///
///
public DataTableSource(DataTable table)
{
this.DataTable = table;
}
///
public object this [int row, int col] => DataTable.Rows[row][col];
///
public int Rows => DataTable.Rows.Count;
///
public int Columns => DataTable.Columns.Count;
///
public string [] ColumnNames => DataTable.Columns.Cast().Select (c => c.ColumnName).ToArray ();
}
}