Beispiel #1
0
        public IEnumerable <IConceptInfo> CreateNewConcepts(SqlIndexMultipleInfo conceptInfo, IDslModel existingConcepts)
        {
            var newConcepts = new List <IConceptInfo>();

            conceptInfo.CheckSemantics(existingConcepts);

            var names = conceptInfo.PropertyNames.Split(' ');

            if (names.Distinct().Count() != names.Count())
            {
                throw new DslSyntaxException(conceptInfo, "Duplicate property name in index list '" + conceptInfo.PropertyNames + "'.");
            }
            if (!names.Any())
            {
                throw new DslSyntaxException(conceptInfo, "Empty property list.");
            }

            SqlIndexMultiplePropertyInfo lastIndexProperty = null;

            for (int i = 0; i < names.Count(); i++)
            {
                var property = new PropertyInfo {
                    DataStructure = conceptInfo.DataStructure, Name = names[i]
                };
                SqlIndexMultiplePropertyInfo indexProperty;
                if (i == 0)
                {
                    indexProperty = new SqlIndexMultiplePropertyInfo {
                        SqlIndex = conceptInfo, Property = property
                    }
                }
                ;
                else
                {
                    indexProperty = new SqlIndexMultipleFollowingPropertyInfo {
                        SqlIndex = conceptInfo, Property = property, PreviousIndexProperty = lastIndexProperty
                    }
                };

                newConcepts.Add(indexProperty);
                lastIndexProperty = indexProperty;
            }

            return(newConcepts);
        }
    }
        public IEnumerable<IConceptInfo> CreateNewConcepts(IEnumerable<IConceptInfo> existingConcepts)
        {
            var newConcepts = new List<IConceptInfo>();

            CheckSemantics(existingConcepts);

            var names = PropertyNames.Split(' ');
            if (names.Distinct().Count() != names.Count())
                throw new DslSyntaxException(this, "Duplicate property name in index list '" + PropertyNames + "'.");
            if (names.Count() == 0)
                throw new DslSyntaxException(this, "Empty property list.");

            SqlIndexMultiplePropertyInfo lastIndexProperty = null;
            for (int i = 0; i < names.Count(); i++)
            {
                var property = new PropertyInfo { DataStructure = DataStructure, Name = names[i] };
                SqlIndexMultiplePropertyInfo indexProperty;
                if (i == 0)
                    indexProperty = new SqlIndexMultiplePropertyInfo { SqlIndex = this, Property = property };
                else
                    indexProperty = new SqlIndexMultipleFollowingPropertyInfo { SqlIndex = this, Property = property, PreviousIndexProperty = lastIndexProperty };

                newConcepts.Add(indexProperty);
                lastIndexProperty = indexProperty;
            }

            return newConcepts;
        }