''DataSet'' ''serializable, diposable'

DataSet serializable, diposable

System.Data (system.data.dll) class

The DataSet contains a collection of DataTable objects that define the schema and contain the data for each table (Tables ). The DataSet also contains a collection of DataRelation objects that define the relationships between the tables (Relations ). The DataSet references a DataViewManager that specifies how views should be created when data binding to a control (DefaultViewManager ). The DataSet is often described as an in-memory cache of relational data.

The DataSet is the only ADO.NET object with the ability to serialize its content to an XML file (using the WriteXml( ) and WriteXmlSchema( ) methods) or to populate itself from an existing schema or XML file (using the ReadXmlSchema( ) and ReadXml( ) methods). Alternatively, you can use GetXml( ) and GetXmlSchema( ) to retrieve the XML data and schema information as a string.

You can delete the data in a DataSet without affecting the schema (using Clear( ) ), create a duplicate DataSet with the same table structure and meta data (using Clone( ) ) or with the same structure and content (using Copy( ) ), merge two DataSet objects (using Merge( ) ), or check the entire DataSet for errors (using HasErrors ).

One of the most important features of the DataSet is its version-tracking ability. By default, each DataRow object in the DataSet stores enough information to track any modifications made to it, and whether it is scheduled for insertion or deletion when reconciled with the data source. The DataAdapter uses this information to reconcile changes and then calls AcceptChanges( ) on each DataRow to replace the original values with the current values. You can retrieve a DataSet with the same schema that contains only modified, deleted, or inserted rows using the GetChanges( ) method.

public class DataSet : System.ComponentModel.MarshalByValueComponent , 
System.ComponentModel.IListSource, System.Xml.Serialization.IXmlSerializable, 
System.ComponentModel.ISupportInitialize, System.Runtime.Serialization.
ISerializable {
// Public Constructors
   public DataSet(  );  
   public DataSet( string dataSetName);  
// Protected Constructors
   protected DataSet(System.Runtime.Serialization.SerializationInfo info, 
        System.Runtime.Serialization.StreamingContext context);
// Public Instance Properties
   public bool CaseSensitive{set; get; } 
   public string DataSetName{set; get; } 
   public DataViewManager DefaultViewManager{get; } 
   public bool EnforceConstraints{set; get; } 
   public PropertyCollection ExtendedProperties{get; } 
   public bool HasErrors{get; } 
   public CultureInfo Locale{set; get; } 
   public string Namespace{set; get; } 
   public string Prefix{set; get; } 
   public DataRelationCollection Relations{get; } 
   public override ISite Site{set; get; }                      // overrides System.ComponentModel.MarshalByValueComponent
   public DataTableCollection Tables{get; } 
// Public Instance Methods
   public void AcceptChanges(  );  
   public void BeginInit(  );                        // implements System.ComponentModel.ISupportInitialize
   public void Clear(  );  
   public virtual DataSet Clone(  );  
   public DataSet Copy(  );  
   public void EndInit(  );                          // implements System.ComponentModel.ISupportInitialize
   public DataSet GetChanges(  );  
   public DataSet GetChanges( DataRowState rowStates);  
   public string GetXml(  );  
   public string GetXmlSchema(  );  
   public bool HasChanges(  );  
   public bool HasChanges( DataRowState rowStates);  
   public void InferXmlSchema(System.IO.Stream stream,  string[ ] nsArray);
   public void InferXmlSchema(string fileName, string[ ] nsArray);
   public void InferXmlSchema(System.IO.TextReader reader,  string[ ] nsArray);
   public void InferXmlSchema(System.Xml.XmlReader reader,  string[ ] nsArray);
   public void Merge( DataRow[ ] rows);  
   public void Merge(DataRow[ ] rows, bool preserveChanges, MissingSchemaAction missingSchemaAction);
   public void Merge( DataSet dataSet);  
   public void Merge( DataSet dataSet, bool preserveChanges);  
   public void Merge(DataSet dataSet, bool preserveChanges, MissingSchemaAction missingSchemaAction);
   public void Merge( DataTable table);  
   public void Merge(DataTable table, bool preserveChanges, MissingSchemaAction missingSchemaAction);
   public XmlReadMode ReadXml( System.IO.Stream stream);  
   public XmlReadMode ReadXml(System.IO.Stream stream, XmlReadMode mode);
   public XmlReadMode ReadXml( string fileName);  
   public XmlReadMode ReadXml(string fileName, XmlReadMode mode);
   public XmlReadMode ReadXml( System.IO.TextReader reader);  
   public XmlReadMode ReadXml(System.IO.TextReader reader, XmlReadMode mode);
   public XmlReadMode ReadXml( System.Xml.XmlReader reader);  
   public XmlReadMode ReadXml(System.Xml.XmlReader reader, XmlReadMode mode);
   public void ReadXmlSchema( System.IO.Stream stream);  
   public void ReadXmlSchema( string fileName);  
   public void ReadXmlSchema( System.IO.TextReader reader);  
   public void ReadXmlSchema( System.Xml.XmlReader reader);  
   public virtual void RejectChanges(  );  
   public virtual void Reset(  );  
   public void WriteXml( System.IO.Stream stream);  
   public void WriteXml(System.IO.Stream stream, XmlWriteMode mode);
   public void WriteXml( string fileName);  
   public void WriteXml( string fileName, XmlWriteMode mode);  
   public void WriteXml( System.IO.TextWriter writer);  
   public void WriteXml(System.IO.TextWriter writer, XmlWriteMode mode);
   public void WriteXml( System.Xml.XmlWriter writer);         // implements System.Xml.Serialization.IXmlSerializable
   public void WriteXml(System.Xml.XmlWriter writer, XmlWriteMode mode);
   public void WriteXmlSchema( System.IO.Stream stream);  
   public void WriteXmlSchema( string fileName);  
   public void WriteXmlSchema( System.IO.TextWriter writer);  
   public void WriteXmlSchema( System.Xml.XmlWriter writer);  
// Protected Instance Methods
   protected virtual XmlSchema GetSchemaSerializable(  );  
   protected void GetSerializationData(System.Runtime.Serialization.SerializationInfo info,
        System.Runtime.Serialization.StreamingContext context);
   protected internal virtual void OnPropertyChanging(System.ComponentModel.PropertyChangedEventArgs pcevent);
   protected virtual void OnRemoveRelation(DataRelation relation);
   protected virtual void OnRemoveTable( DataTable table);  
   protected internal void RaisePropertyChanging(string name);
   protected virtual void ReadXmlSerializable(System.Xml.XmlReader reader);
   protected virtual bool ShouldSerializeRelations(  );  
   protected virtual bool ShouldSerializeTables(  );  
// Events
   public event MergeFailedEventHandler MergeFailed;  


System.Object figs/U2192.gif System.ComponentModel.MarshalByValueComponent(System.ComponentModel.IComponent, System.IDisposable , System.IServiceProvider) figs/U2192.gif DataSet(System.ComponentModel.IListSource, System.Xml.Serialization.IXmlSerializable , System.ComponentModel.ISupportInitialize , System.Runtime.Serialization.ISerializable)

Returned By

DataRelation.DataSet , DataRelationCollection.GetDataSet( ) , DataTable.DataSet , DataViewManager.DataSet , System.Xml.XmlDataDocument.DataSet

Passed To

Multiple types

    Part I: ADO.NET Tutorial
    Part II: ADO.NET Core Classes
    Part III: API Quick Reference
    Chapter 34. The System.Data Namespace