DataRowCollection.cs (InsertAt): Add a check for null row. Replace check of IndexOf...
authorEran Domb <eran@mono-cvs.ximian.com>
Wed, 4 Feb 2004 06:18:41 +0000 (06:18 -0000)
committerEran Domb <eran@mono-cvs.ximian.com>
Wed, 4 Feb 2004 06:18:41 +0000 (06:18 -0000)
better performance.
DataSet.cs (GetTableSchema) : Add supprot for simple content columns. Change the condition for a case
when all column are attributes (elements count is 0), we still want to add the relations. No relations
can be on simple contents.
(AddUniqueConstraints) Check that the column of the constraint are not hidden.
(AddForeignKeys) Check that the relation has constraints attach to it.
XmlConstants.cs : Added constant.

svn path=/trunk/mcs/; revision=22758

mcs/class/System.Data/System.Data/ChangeLog
mcs/class/System.Data/System.Data/DataRowCollection.cs
mcs/class/System.Data/System.Data/DataSet.cs
mcs/class/System.Data/System.Data/XmlConstants.cs

index 63609bf517f956822c27f9f0c885e5b49a7e9850..9c613e299890143ca8fa5c4041e874847cfc5169 100644 (file)
@@ -1,3 +1,14 @@
+2004-02-04 Eran Domb <erand@mainsoft.com>
+
+       * DataRowCollection.cs (InsertAt): Add a check for null row. Replace check of IndexOf with RowId for
+       better performance.
+       * DataSet.cs (GetTableSchema) : Add supprot for simple content columns. Change the condition for a case
+       when all column are attributes (elements count is 0), we still want to add the relations. No relations
+       can be on simple contents.
+       (AddUniqueConstraints) Check that the column of the constraint are not hidden.
+       (AddForeignKeys) Check that the relation has constraints attach to it.
+       * XmlConstants.cs : Added constant.
+
 2004-02-04 Eran Domb <erand@mainsoft.com>
        
        * DataSet.cs : GetSchemaSerializable() return null and not BuildSchema().
index f4f809f3710b2e3f1952d9504c2c73d95f5cb06f..b55e04640356332048c1bb5a067c686531a5e489 100644 (file)
@@ -237,11 +237,15 @@ namespace System.Data
                {
                        if (pos < 0)
                                throw new IndexOutOfRangeException ("The row insert position " + pos + " is invalid.");
-                               
+                       
+                       if (row == null)
+                               throw new ArgumentNullException("row", "'row' argument cannot be null.");
+       
                        if (row.Table != this.table)
                                throw new ArgumentException ("This row already belongs to another table.");
 
-                       if (list.IndexOf(row) != -1)
+                       // If row id is not -1, we know that it is in the collection.
+                       if (row.RowID != -1)
                                throw new ArgumentException ("This row already belongs to this table.");
                        
                        if ((table.DataSet == null || table.DataSet.EnforceConstraints) && !table._duringDataLoad)
index f4d5e0ef1248de95a6582b50bc1681b841f22942..d61c750c36e1648eb46ef899ccc0478cd2369951 100644 (file)
@@ -1332,6 +1332,18 @@ namespace System.Data {
                                                UniqueConstraint uqConst = (UniqueConstraint)constaint;
                                                XmlSchemaUnique uniq = new XmlSchemaUnique ();
                                                
+                                               // if column of the constraint is hidden do not write the constraint.
+                                               bool isHidden = false;
+                                               foreach (DataColumn column in uqConst.Columns) {
+                                                       if (column.ColumnMapping == MappingType.Hidden) {
+                                                               isHidden = true;
+                                                               break;
+                                                       }
+                                               }
+
+                                               if (isHidden)
+                                                       continue;
+
                                                // if constaraint name do not exist in the hashtable we can use it.
                                                if (!uniqueNames.ContainsKey (uqConst.ConstraintName)) {
                                                        uniq.Name = uqConst.ConstraintName;
@@ -1376,6 +1388,9 @@ namespace System.Data {
                        XmlDocument doc = new XmlDocument();
                        foreach (DataRelation rel in relations) {
                                
+                               if (rel.ParentKeyConstraint == null || rel.ChildKeyConstraint == null)
+                                       continue;
+                               
                                ArrayList attrs = new ArrayList ();
                                XmlAttribute attrib;
                                XmlSchemaKeyref keyRef = new XmlSchemaKeyref();
@@ -1426,7 +1441,27 @@ namespace System.Data {
                        elem.SchemaType = complex;
 
                        //TODO - what about the simple content?
-                       if (elements.Count == 0) {                              
+                       if (simple != null) {
+                               // add simpleContent
+                               XmlSchemaSimpleContent simpleContent = new XmlSchemaSimpleContent();
+                               complex.ContentModel = simpleContent;
+
+                               // add column name attribute
+                               XmlAttribute[] xlmAttrs = new XmlAttribute [2];
+                               xlmAttrs[0] = doc.CreateAttribute (XmlConstants.MsdataPrefix,  XmlConstants.ColumnName, XmlConstants.MsdataNamespace);
+                               xlmAttrs[0].Value = simple.ColumnName;
+                               
+                               // add ordinal attribute
+                               xlmAttrs[1] = doc.CreateAttribute (XmlConstants.MsdataPrefix, XmlConstants.Ordinal, XmlConstants.MsdataNamespace);
+                               xlmAttrs[1].Value = simple.Ordinal.ToString();
+                               simpleContent.UnhandledAttributes = xlmAttrs;
+                               
+                               
+                               // add extension
+                               XmlSchemaSimpleContentExtension extension = new XmlSchemaSimpleContentExtension();
+                               simpleContent.Content = extension;
+                               extension.BaseTypeName = MapType (simple.DataType);
+                       
                        }
                        else {
                                //A sequence of element types or a simple content node
index 87c930d3f8dae71e2f1d556355b2a79f404c4b24..43fa64d4d5bc4b6f8b8e4f772c944785f29dbc57 100755 (executable)
@@ -70,6 +70,7 @@ internal class XmlConstants
        public const string RelationName = "RelationName";
        public const string ConstraintName = "ConstraintName";
        public const string PrimaryKey = "PrimaryKey";
+       public const string ColumnName = "ColumnName";
 
        public static XmlQualifiedName QnString = new XmlQualifiedName ("string", XmlSchema.Namespace);
        public static XmlQualifiedName QnShort = new XmlQualifiedName ("short", XmlSchema.Namespace);