SqlDataView
Represents a SQL data view. This class cannot be inherited, backwards compatibility isn't guaranteed, and should never be consumed by API users.
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Runtime.Serialization;
namespace Relativity.DataExchange.Data
{
[Serializable]
public sealed class SqlDataView : MarshalByRefObject, IEnumerable, ISerializable
{
[NonSerialized]
private readonly DataView dataview;
public DataTable Table => dataview.Table;
public int Count => dataview.Count;
public SqlDataRow this[int index] {
get {
return new SqlDataRow(dataview[index]);
}
}
public SqlDataView(DataTable table)
{
if (table == null)
throw new ArgumentNullException("table");
dataview = new DataView(table);
}
public SqlDataView(DataSet dataset)
{
if (dataset == null)
throw new ArgumentNullException("dataset");
if (dataset.Tables.Count < 1)
throw new ArgumentException("The dataset must contain at least 1 table.", "dataset");
dataview = new DataView(dataset.Tables[0]);
}
private SqlDataView(SerializationInfo info, StreamingContext context)
{
if (info == null)
throw new ArgumentNullException("info");
dataview = new DataView();
dataview.Table = (DataTable)info.GetValue("Table", typeof(DataTable));
dataview.AllowDelete = info.GetBoolean("AllowDelete");
dataview.AllowEdit = info.GetBoolean("AllowEdit");
dataview.AllowNew = info.GetBoolean("AllowNew");
dataview.ApplyDefaultSort = info.GetBoolean("ApplyDefaultSort");
dataview.RowStateFilter = (DataViewRowState)info.GetValue("RowStateFilter", typeof(DataViewRowState));
dataview.Site = (ISite)info.GetValue("Site", typeof(ISite));
}
public IEnumerator GetEnumerator()
{
return dataview.GetEnumerator();
}
public void GetObjectData(SerializationInfo info, StreamingContext context)
{
if (info == null)
throw new ArgumentNullException("info");
info.AddValue("Table", Table);
info.AddValue("AllowDelete", dataview.AllowDelete);
info.AddValue("AllowEdit", dataview.AllowEdit);
info.AddValue("AllowNew", dataview.AllowNew);
info.AddValue("ApplyDefaultSort", dataview.ApplyDefaultSort);
info.AddValue("RowStateFilter", dataview.RowStateFilter);
info.AddValue("Site", dataview.Site);
}
}
}