2 // System.Data.DataRowCollection.cs
5 // Daniel Morgan <danmorg@sc.rr.com>
6 // Tim Coleman <tim@timcoleman.com>
8 // (C) Ximian, Inc 2002
9 // (C) Copyright 2002 Tim Coleman
10 // (C) Copyright 2002 Daniel Morgan
14 using System.Collections;
15 using System.ComponentModel;
20 /// Collection of DataRows in a DataTable
23 public class DataRowCollection : InternalDataCollectionBase
25 private DataTable table;
28 /// Internal constructor used to build a DataRowCollection.
30 protected internal DataRowCollection (DataTable table) : base ()
36 /// Gets the row at the specified index.
38 public DataRow this[int index]
40 get { return (DataRow) list[index]; }
44 /// This member overrides InternalDataCollectionBase.List
46 protected internal override ArrayList List
52 /// Adds the specified DataRow to the DataRowCollection object.
54 public void Add (DataRow row)
59 row.RowStateInternal = DataRowState.Added;
63 /// Creates a row using specified values and adds it to the DataRowCollection.
65 public virtual DataRow Add (object[] values)
67 DataRow row = table.NewRow ();
68 row.ItemArray = values;
74 /// Clears the collection of all rows.
83 /// Gets a value indicating whether the primary key of any row in the collection contains
84 /// the specified value.
87 public bool Contains (object key)
89 throw new NotImplementedException ();
93 /// Gets a value indicating whether the primary key column(s) of any row in the
94 /// collection contains the values specified in the object array.
97 public bool Contains (object[] keys)
99 throw new NotImplementedException ();
103 /// Gets the row specified by the primary key value.
106 public DataRow Find (object key)
108 throw new NotImplementedException ();
112 /// Gets the row containing the specified primary key values.
115 public DataRow Find (object[] keys)
117 throw new NotImplementedException ();
121 /// Inserts a new row into the collection at the specified location.
123 public void InsertAt (DataRow row, int pos)
125 list.Insert (pos, row);
129 /// Removes the specified DataRow from the collection.
131 public void Remove (DataRow row)
137 /// Removes the row at the specified index from the collection.
139 public void RemoveAt (int index)
141 list.RemoveAt (index);
145 ///Internal method used to validate a given DataRow with respect
146 ///to the DataRowCollection
149 internal void ValidateDataRowInternal(DataRow row)
151 //FIXME: this validates constraints in the order they appear
152 //in the collection. Most probably we need to do it in a
153 //specific order like unique/primary keys first, then Foreignkeys, etc
154 foreach(Constraint constraint in table.Constraints)
156 constraint.AssertConstraint(row);