public EntityFieldCollectionEnumerator(EntityFieldCollection mappings) : base(mappings) {}
private void btnFieldAutoIndex_Click(object sender, EventArgs e) { // Create Objects EntityFieldCollection entityFieldCollection = new EntityFieldCollection(); EntityField field; Entity entity; Index tmpNewIndex; IndexField tmpNewIndexField; Boolean bSub; // Get Selected Field field = (EntityField) GetSelectedItemOfType(typeof (EntityField)); // Get Current Entity entity = this.designView.CurrentEntity; // Check if Index exists if (field == null) // Create All Field Index { // Get All Fields entityFieldCollection = entity.Fields; } else { entityFieldCollection.Add(field); } // Looping on entityFieldCollection foreach (EntityField tmpEntityField in entityFieldCollection) { // Clear Found Flag bSub = false; // Check the Index Exists foreach(Index tmpIndex in entity.Indexes) { // Index Alread exists, Set Found Flag if (tmpIndex.Name.Equals(tmpEntityField.Name)) { bSub = true; break; } } if (! bSub) // Check's Found Flag { // Create Index tmpNewIndex = new Index(); tmpNewIndex.Name = tmpEntityField.Name; tmpNewIndex.PrimaryKey = tmpEntityField.KeyField; tmpNewIndex.Unique = tmpEntityField.DBIdentity; tmpNewIndex.SelectBy = true; tmpNewIndex.DeleteBy = tmpEntityField.KeyField; entity.Indexes.Add(tmpNewIndex); // Create Index Fields tmpNewIndexField = new IndexField(); tmpNewIndexField.Name = tmpEntityField.Name; tmpNewIndexField.ParameterName = tmpEntityField.Name; tmpNewIndex.Fields.Add(tmpNewIndexField); } } TreeNode rootNode = GetSelectedNodeOfType(typeof (Entity)); TreeNode indexesNode = rootNode.Nodes[1]; // Refresh List this.designView.RefreshIndexesList(indexesNode, entity, false); }