/// <summary> /// Creates a <see cref="ClassDefinition"/> from this instance /// </summary> /// <param name="createAutoGeneratedId">If true, will add an auto-generated id property to this class definition</param> /// <returns>The class definition</returns> public ClassDefinition CreateClassDefinition(bool createAutoGeneratedId) { ClassDefinition cd = null; if (!string.IsNullOrEmpty(this.GeometryColumn)) { FeatureClass fc = new FeatureClass(this.TableName, string.Empty); GeometricPropertyDefinition gp = new GeometricPropertyDefinition(this.GeometryColumn, string.Empty); fc.Properties.Add(gp); fc.GeometryProperty = gp; cd = fc; } else { cd = new Class(this.TableName, string.Empty); } if (createAutoGeneratedId) { int num = 1; string name = "AutoID"; string genName = name + num; string theName = string.Empty; if (this.Columns[name] != null) { while (this.Columns[genName] != null) { genName = name + (num++); } theName = genName; } else { theName = name; } DataPropertyDefinition id = new DataPropertyDefinition(theName, string.Empty); id.IsAutoGenerated = true; id.DataType = DataType.DataType_Int32; cd.Properties.Add(id); cd.IdentityProperties.Add(id); } //Now process columns foreach (DataColumn dc in this.Columns) { if (dc.ColumnName != this.GeometryColumn) { DataPropertyDefinition dp = ExpressUtility.GetDataPropertyForColumn(dc); cd.Properties.Add(dp); } } return(cd); }