예제 #1
0
        private string CompoundIndex(AtomIndexDefinition index)
        {
            var indexMembers = index.GetIndexMembers(_data);

            string
                IndexType = "NONCLUSTERED",
                TableName = _data.Name,
                Schema = _data.AdditionalInfo.Schema,
                IndexPrefix = "IX",
                Columns = string.Join("_", indexMembers.Select(i => i.Name)),
                SpacedColumns = string.Join(", ", indexMembers.Select(BuildIndexColumnDef));

            return $@"CREATE {IndexType} INDEX [{IndexPrefix}_{TableName}_{Columns}] ON [{Schema}].[{TableName}] ({SpacedColumns}) ON [PRIMARY]";
        }
예제 #2
0
        private IEnumerable<AtomIndexDefinition> GetAtomIndexMembers(List<string> groups)
        {
            if (groups == null || groups.Count == 0)
            {
                yield break;
            }

            var relatedGroups = _data.Members.Where(member => member.Groups?.Count > 0)
                                 .Where(member => groups.Any(member.Groups.Contains))
                                 .SelectMany(
                                     member => member.Groups.Select(
                                         groupName => new
                                         {
                                             member,
                                             groupName = groupName
                                         }))
                                 .GroupBy(i => i.groupName);

            foreach (var grouping in relatedGroups)
            {
                AtomGroupDefinition group;

                if (!_data.Groups.TryGetValue(grouping.Key, out group))
                {
                    continue;
                }

                var indexDef = new AtomIndexDefinition
                {
                    Unique = group.Unique,
                    Columns = grouping.Select(i => i.member.Name).ToList()
                };
            }
        }