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

            var property = DslUtility.CreatePassiveClone(conceptInfo.Source, conceptInfo.Destination);

            newConcepts.Add(property);

            var required = existingConcepts.FindByReference <RequiredPropertyInfo>(ci => ci.Property, conceptInfo.Source)
                           .Select(ci => new RequiredPropertyInfo {
                Property = property
            })
                           .SingleOrDefault();

            if (required != null)
            {
                newConcepts.Add(required);
            }

            if (SqlIndexMultipleInfo.IsSupported(conceptInfo.Destination))
            {
                foreach (var sourceIndex in existingConcepts.FindByReference <SqlIndexMultipleInfo>(ci => ci.DataStructure, conceptInfo.Source.DataStructure))
                {
                    var indexProperties = sourceIndex.PropertyNames.Split(' ');
                    if (property.Name == indexProperties.FirstOrDefault() &&
                        indexProperties.Skip(1).All(indexProperty =>
                                                    DslUtility.FindProperty(existingConcepts, conceptInfo.Destination, indexProperty) != null))
                    {
                        newConcepts.Add(new SqlIndexMultipleInfo {
                            DataStructure = conceptInfo.Destination, PropertyNames = sourceIndex.PropertyNames
                        });
                    }
                }
            }

            return(newConcepts);
        }