Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRodrigo Moya <rodrigo@mono-cvs.ximian.com>2002-10-02 02:24:31 +0400
committerRodrigo Moya <rodrigo@mono-cvs.ximian.com>2002-10-02 02:24:31 +0400
commit454dcdbf1445466bc1d4a5a7680e3120c541a45b (patch)
treea824ca9f2d3122d81c8a6d04b0442964c3a87921
parentf1e2dea61743d39758486260e9365ea9e426da46 (diff)
2002-10-01 Luis Fernandez <luifer@onetel.net.uk>
* System.Data/DataColumn.cs: * System.Data/DataRow.cs: * System.Data/DataRowCollection.cs: * System.Data/DataTable.cs: some fixes and implementation. svn path=/trunk/mcs/; revision=7921
-rw-r--r--mcs/class/System.Data/ChangeLog9
-rw-r--r--mcs/class/System.Data/System.Data/DataColumn.cs26
-rw-r--r--mcs/class/System.Data/System.Data/DataRow.cs53
-rw-r--r--mcs/class/System.Data/System.Data/DataRowCollection.cs1
-rw-r--r--mcs/class/System.Data/System.Data/DataTable.cs9
5 files changed, 94 insertions, 4 deletions
diff --git a/mcs/class/System.Data/ChangeLog b/mcs/class/System.Data/ChangeLog
index 56a3e3a8ab1..afffdfb5681 100644
--- a/mcs/class/System.Data/ChangeLog
+++ b/mcs/class/System.Data/ChangeLog
@@ -1,4 +1,11 @@
-2002-09-28 Vladimir Vukicevic  <vladimir@pobox.com>
+2002-10-01 Luis Fernandez <luifer@onetel.net.uk>
+
+ * System.Data/DataColumn.cs:
+ * System.Data/DataRow.cs:
+ * System.Data/DataRowCollection.cs:
+ * System.Data/DataTable.cs: some fixes and implementation.
+
+2002-09-28 Vladimir Vukicevic <vladimir@pobox.com>
* System.Data.OleDb/OleDbConnection.cs: Close
reader properly in call to ExecuteScalar().
diff --git a/mcs/class/System.Data/System.Data/DataColumn.cs b/mcs/class/System.Data/System.Data/DataColumn.cs
index efea6d513da..10cda87d34a 100644
--- a/mcs/class/System.Data/System.Data/DataColumn.cs
+++ b/mcs/class/System.Data/System.Data/DataColumn.cs
@@ -365,7 +365,33 @@ namespace System.Data
//TODO: create UniqueConstraint
//if Table == null then the constraint is
//created on addition to the collection
+
+ //FIXME?: need to check if value is the same
+ //because when calling "new UniqueConstraint"
+ //the new object tries to set "column.Unique = True"
+ //which creates an infinite loop.
+ if(unique != value)
+ {
unique = value;
+
+ if( value )
+ {
+ if( _table != null )
+ {
+ UniqueConstraint uc = new UniqueConstraint(this);
+ _table.Constraints.Add(uc);
+ }
+ }
+ else
+ {
+ if( _table != null )
+ {
+ //FIXME: Add code to remove constraint from DataTable
+ throw new NotImplementedException ();
+ }
+ }
+
+ }
}
}
diff --git a/mcs/class/System.Data/System.Data/DataRow.cs b/mcs/class/System.Data/System.Data/DataRow.cs
index f4b1d33e2e9..ec1b514875b 100644
--- a/mcs/class/System.Data/System.Data/DataRow.cs
+++ b/mcs/class/System.Data/System.Data/DataRow.cs
@@ -52,7 +52,10 @@ namespace System.Data
columnErrors = new string[_table.Columns.Count];
rowError = String.Empty;
- rowState = DataRowState.Unchanged;
+ //rowState = DataRowState.Unchanged;
+
+ //on first creating a DataRow it is always detached.
+ rowState = DataRowState.Detached;
}
#endregion
@@ -108,12 +111,32 @@ namespace System.Data
if (rowState == DataRowState.Deleted)
throw new DeletedRowInaccessibleException ();
+ //MS Implementation doesn't seem to create the proposed or original
+ //set of values when a datarow has just been created or added to the
+ //DataTable and AcceptChanges() has not been called yet.
+ if(rowState == DataRowState.Detached || rowState == DataRowState.Added)
+ {
+ if(objIsDBNull)
+ current[columnIndex] = DBNull.Value;
+ else
+ current[columnIndex] = value;
+
+ }
+ else
+ {
BeginEdit (); // implicitly called
if(objIsDBNull)
proposed[columnIndex] = DBNull.Value;
else
proposed[columnIndex] = value;
- EndEdit (); // is this the right thing to do?
+ }
+
+ //Don't know if this is the rigth thing to do,
+ //but it fixes my test. I believe the MS docs only say this
+ //method is implicitly called when calling AcceptChanges()
+
+ //EndEdit (); // is this the right thing to do?
+
}
}
@@ -245,6 +268,13 @@ namespace System.Data
get { return rowState; }
}
+ //FIXME?: Couldn't find a way to set the RowState when adding the DataRow
+ //to a Datatable so I added this method. Delete if there is a better way.
+ internal DataRowState RowStateInternal
+ {
+ set { rowState = value;}
+ }
+
/// <summary>
/// Gets the DataTable for which this row has a schema.
/// </summary>
@@ -263,6 +293,14 @@ namespace System.Data
[MonoTODO]
public void AcceptChanges ()
{
+
+ if(rowState == DataRowState.Added)
+ {
+ //Instantiate original and proposed values so that we can call
+ //EndEdit()
+ this.BeginEdit();
+ }
+
this.EndEdit ();
switch (rowState)
@@ -278,7 +316,10 @@ namespace System.Data
break;
}
- original = null;
+ //MS implementation assigns the Proposed values
+ //to both current and original and keeps original after calling AcceptChanges
+ //Copy proposed to original in this.EndEdit()
+ //original = null;
}
/// <summary>
@@ -355,6 +396,12 @@ namespace System.Data
rowState = DataRowState.Modified;
//TODO: Validate Constraints, Events
Array.Copy (proposed, current, _table.Columns.Count);
+
+ //FIXME: MS implementation assigns the proposed values to
+ //the original values. Should this be done here or on the
+ //AcceptChanges() method?
+ Array.Copy (proposed, original, _table.Columns.Count);
+
proposed = null;
}
}
diff --git a/mcs/class/System.Data/System.Data/DataRowCollection.cs b/mcs/class/System.Data/System.Data/DataRowCollection.cs
index 79f5a57bb96..ca98c053d44 100644
--- a/mcs/class/System.Data/System.Data/DataRowCollection.cs
+++ b/mcs/class/System.Data/System.Data/DataRowCollection.cs
@@ -55,6 +55,7 @@ namespace System.Data
//TODO: AutoIncrement
//TODO: validation
list.Add (row);
+ row.RowStateInternal = DataRowState.Added;
}
/// <summary>
diff --git a/mcs/class/System.Data/System.Data/DataTable.cs b/mcs/class/System.Data/System.Data/DataTable.cs
index 1d69e2c296d..a7a3a646362 100644
--- a/mcs/class/System.Data/System.Data/DataTable.cs
+++ b/mcs/class/System.Data/System.Data/DataTable.cs
@@ -381,6 +381,15 @@ namespace System.Data
public void AcceptChanges()
{
+
+ //FIXME: Do we need to validate anything here or
+ //try to catch any errors to deal with them?
+
+ foreach(DataRow myRow in _rows)
+ {
+ myRow.AcceptChanges();
+ }
+
}
/// <summary>