Browse Source

fix for #74813

svn path=/trunk/mcs/; revision=45165
Konstantin Triger 20 years ago
parent
commit
09baa14599

+ 7 - 0
mcs/class/System.Data/System.Data/ChangeLog

@@ -1,3 +1,10 @@
+2005-05-29 Konstantin Triger <[email protected]>
+
+	* This patch fixes #74813
+	* DataView.cs: rework the CreateChildView to receive the index into the indexed row array, rowState became protected to be initialized from RelatedDataView
+	* DataRowView.cs: movo the logic of creating the child view to the DataView
+	* RelatedDataView.cs: perform correct init.
+
 2005-05-25  Sureshkumar T  <[email protected]>
 
 	* DataTable.cs: Reworked DataTable.LoadDataRow method after

+ 1 - 9
mcs/class/System.Data/System.Data/DataRowView.cs

@@ -90,17 +90,9 @@ namespace System.Data
 			}
 		}
 
-		[MonoTODO]
 		public DataView CreateChildView (DataRelation relation)
 		{
-			if (relation == null)
-				throw new ArgumentException ("The relation is not parented to the table.");
-			// FIXME : provide more efficient implementation using records
-			object[] keyValues = new object[relation.ParentColumns.Length];
-			for(int i=0; i < relation.ParentColumns.Length; i++) {
-				keyValues[i] = this[relation.ParentColumns[i].Ordinal];
-			}
-			return DataView.CreateChildView(relation,keyValues);
+			return DataView.CreateChildView(relation,_index);
 		}
 
 		public DataView CreateChildView (string name)

+ 7 - 14
mcs/class/System.Data/System.Data/DataView.cs

@@ -40,7 +40,7 @@ namespace System.Data
 		string rowFilter = String.Empty;
 		IExpression rowFilterExpr;
 		string sort = String.Empty;
-		DataViewRowState rowState;
+		protected DataViewRowState rowState;
 		protected DataRowView[] rowCache = null;
 
 		// BeginInit() support
@@ -1045,25 +1045,18 @@ namespace System.Data
 			sort = builder.ToString();
 		}
 		
-		// FIXME : complete the implementation
-		internal DataView CreateChildView (DataRelation relation,object[] keyValues)
+		internal DataView CreateChildView (DataRelation relation, int index)
 		{
 			if (relation == null || relation.ParentTable != Table) {
 				throw new ArgumentException("The relation is not parented to the table to which this DataView points.");
 			}
-			return new RelatedDataView(relation.ChildColumns,keyValues);
-		}
-
-		// FIXME : complete the implementation
-		internal DataView CreateChildView (string name,object[] keyValues)
-		{
-			DataRelation relation = Table.ChildRelations[name];
 
-			if (relation != null) {
-				return CreateChildView(relation,keyValues);
-			}
+			int record = GetRecord(index);
+			object[] keyValues = new object[relation.ParentColumns.Length];
+			for(int i=0; i < relation.ParentColumns.Length; i++)
+				keyValues [i] = relation.ParentColumns [i][record];
 
-			throw new ArgumentException("Relation " + name + " not found in the table");
+			return new RelatedDataView(relation.ChildColumns,keyValues);
 		}
 
 		private int GetRecord(int index) {

+ 2 - 1
mcs/class/System.Data/System.Data/RelatedDataView.cs

@@ -28,10 +28,11 @@ namespace System.Data
 		internal RelatedDataView(DataColumn[] relatedColumns,object[] keyValues)
 		{
 			dataTable = relatedColumns[0].Table;
+			rowState = DataViewRowState.CurrentRows;
 			_columns = relatedColumns;
 			_keyValues = keyValues;
 
-			UpdateIndex(true);
+			Open();
 		}
 
 		#endregion // Constructors