private void RectangleDrop(object sender, DragEventArgs e) { var property = (string)e.Data.GetData(DataFormats.StringFormat); var desc = new IndexDescriptor(); desc.IndexedProperties.Add(new IndexDescriptorProperty { PropertyName = property }); AddIndex(desc); }
private void PopulateList(IEnumerable<CollectionProperty> properties) { properties.ToList().ForEach( prop => _properties.Add(prop.FullName)); var idxs = MongoUtilities.Create(_connection).GetDatabase(_database).GetCollection(_collectionName).GetIndexes(); foreach (var idx in idxs) { var descriptor = new IndexDescriptor { IsSparse = idx.IsSparse, IsUnique = idx.IsUnique }; var names = idx.Key.Names.ToArray(); for (int i = 0; i < names.Length; i++) { if (names[i] == "_id" && names.Length == 1) { continue; } var prop = new IndexDescriptorProperty { PropertyName = names[i] }; if (idx.Key[i].BsonType == MongoDB.Bson.BsonType.String) { prop.IndexType = IndexType.Geospatial; } else { if (idx.Key[i].ToInt32() > 0) { prop.IndexType = IndexType.Ascending; } else { prop.IndexType = IndexType.Descending; } } descriptor.IndexedProperties.Add(prop); } if (descriptor.IndexedProperties.Count > 0) { _dialog.IndexList.AddIndex(descriptor); } } }
public void AddIndex(IndexDescriptor index) { index.Id = _nextId++; _indexes.Add(index); }