public override void Modify(DocumentMapping mapping, MemberInfo member)
            {
                var membersGroupedByIndexName = member.DeclaringType.GetMembers()
                                                .Where(mi => mi.GetCustomAttributes <UniqueIndexAttribute>().Any())
                                                .Select(mi => new
                {
                    Member           = mi,
                    IndexInformation = mi.GetCustomAttributes <UniqueIndexAttribute>().First()
                })
                                                .GroupBy(m => m.IndexInformation.IndexName ?? m.Member.Name)
                                                .Where(mg => mg.Any(m => m.Member == member))
                                                .Single();

                //var indexDefinition = new ComputedIndex(mapping, new[] { member })
                var indexDefinition = new UniqueIndex(mapping, membersGroupedByIndexName.Select(m => new[] { m.Member }).ToArray())
                {
                    Method = IndexMethod
                };

                if (IndexName.IsNotEmpty())
                {
                    indexDefinition.IndexName = IndexName;
                }

                indexDefinition.IsUnique = true;

                if (!mapping.Indexes.Any(ind => ind.IndexName == indexDefinition.IndexName))
                {
                    mapping.Indexes.Add(indexDefinition);
                }
            }
Esempio n. 2
0
        public override void Modify(DocumentMapping mapping, MemberInfo member)
        {
            var field           = mapping.DuplicateField(member.Name, PgType);
            var indexDefinition = mapping.AddIndex(field.ColumnName);

            indexDefinition.Method = IndexMethod;
            if (IndexName.IsNotEmpty())
            {
                indexDefinition.IndexName = IndexName;
            }
        }
Esempio n. 3
0
        public override void Modify(DocumentMapping mapping, MemberInfo member)
        {
            var field = mapping.DuplicateField(member.Name, PgType, notNull: NotNull);

            if (DbType != default)
            {
                field.DbType = DbType;
            }

            var indexDefinition = mapping.AddIndex(field.ColumnName);

            indexDefinition.Method = IndexMethod;
            if (IndexName.IsNotEmpty())
            {
                indexDefinition.IndexName = IndexName;
            }

            indexDefinition.SortOrder = IndexSortOrder;
        }