示例#1
0
文件: EntityInfo.cs 项目: sGeeK44/Orm
        private void TreatFieldAttribute(PropertyInfo prop, FieldAttribute fieldAttribute)
        {
            if (fieldAttribute == null)
            {
                return;
            }

            if (Fields.Contains(fieldAttribute.Key))
            {
                return;
            }

            var field = CreateField(prop, fieldAttribute);

            if (fieldAttribute.SearchOrder != FieldSearchOrder.NotSearchable ||
                fieldAttribute.RequireUniqueValue)
            {
                var newIndex = Index.CreateStandard(GetNameInStore(), field);
                Indexes.Add(newIndex);
            }

            foreach (var index in fieldAttribute.Indexes)
            {
                if (!Indexes.Contains(index))
                {
                    var newIndex = Index.CreateCustom(index, GetNameInStore(), field);
                    Indexes.Add(newIndex);
                }
                else
                {
                    Indexes[index].AddField(field);
                }
            }

            foreach (var indexProperties in _attributes.Where(_ => _ is IndexPropertiesAttribute)
                     .Cast <IndexPropertiesAttribute>())
            {
                if (!Indexes.Contains(indexProperties.IndexName))
                {
                    continue;
                }

                var index = Indexes[indexProperties.IndexName];
                index.IsUnique    = indexProperties.RequireUniqueValue;
                index.SearchOrder = indexProperties.SearchOrder;
            }
        }
示例#2
0
 public void VerifyIndex(Index index)
 {
     _schemaChecker.VerifyIndex(index);
 }