public void ApplyMapping(IEntityDefinition definition, BsonClassMap classMap)
 {
     definition.Indexes = definition.TraverseProperties().SelectMany(p =>
                                                                     p.PropertyInfo.GetCustomAttributes <IndexAttribute>().Select(a => new EntityIndex
     {
         Property      = p,
         IndexName     = a.Name,
         IsUnique      = a.IsUnique,
         SortOrder     = a.SortOrder,
         IndexPriority = a.IndexPriority
     })
                                                                     );
 }
        public void ApplyMapping(IEntityDefinition definition, BsonClassMap classMap)
        {
            var definitionIndexes = new List <EntityIndex>();

            foreach (var property in definition.TraverseProperties())
            {
                foreach (var indexAttribute in property.PropertyInfo.GetCustomAttributes <IndexAttribute>())
                {
                    definitionIndexes.Add(new EntityIndex
                    {
                        Property      = property,
                        IndexName     = indexAttribute.Name,
                        IsUnique      = indexAttribute.IsUnique,
                        SortOrder     = indexAttribute.SortOrder,
                        IndexPriority = indexAttribute.IndexPriority,
                        IndexType     = indexAttribute.IndexType
                    });
                }
            }

            definition.Indexes = definitionIndexes;
        }