Ejemplo n.º 1
0
        public AutoMapReduceIndexDefinition(string collection, AutoIndexField[] mapFields, AutoIndexField[] groupByFields)
            : base(AutoIndexNameFinder.FindMapReduceIndexName(collection, mapFields, groupByFields), collection, mapFields)
        {
            GroupByFields = groupByFields.ToDictionary(x => x.Name, x => x, StringComparer.Ordinal);

            MapAndGroupByFields = new Dictionary <string, AutoIndexField>(MapFields.Count + GroupByFields.Count);

            foreach (var field in MapFields)
            {
                MapAndGroupByFields[field.Key] = field.Value.As <AutoIndexField>();
            }

            foreach (var field in GroupByFields)
            {
                MapAndGroupByFields[field.Key] = field.Value;

                foreach (var indexField in field.Value.ToIndexFields())
                {
                    IndexFields.Add(indexField.Name, indexField);
                }
            }
        }
Ejemplo n.º 2
0
        public AutoMapReduceIndexDefinition(string collection, AutoIndexField[] mapFields, AutoIndexField[] groupByFields, IndexDeploymentMode?deploymentMode, long?indexVersion = null)
            : base(AutoIndexNameFinder.FindMapReduceIndexName(collection, mapFields, groupByFields), collection, mapFields, deploymentMode, indexVersion)
        {
            OrderedGroupByFields = groupByFields.OrderBy(x => x.Name, StringComparer.Ordinal).ToArray();

            GroupByFields = groupByFields.ToDictionary(x => x.Name, x => x, StringComparer.Ordinal);

            MapAndGroupByFields = new Dictionary <string, AutoIndexField>(MapFields.Count + GroupByFields.Count);

            foreach (var field in MapFields)
            {
                MapAndGroupByFields[field.Key] = field.Value.As <AutoIndexField>();
            }

            foreach (var field in GroupByFields)
            {
                MapAndGroupByFields[field.Key] = field.Value;

                foreach (var indexField in field.Value.ToIndexFields())
                {
                    IndexFields.Add(indexField.Name, indexField);
                }
            }
        }