public static string ConstraintName(SqlIndexMultipleInfo info)
 {
     var cleanColumnNames = info.PropertyNames.Split(' ').Select(name => name.Trim()).ToArray();
     var joinedColumnNames = string.Join("_", cleanColumnNames.Select(CsUtility.TextToIdentifier));
     var basicConstraintName = Sql.Format("SqlIndexMultipleDatabaseDefinition_ConstraintName", info.DataStructure.Name, joinedColumnNames);
     return SqlUtility.Identifier(basicConstraintName);
 }
 public void InitializeNonparsableProperties(out IEnumerable <IConceptInfo> createdConcepts)
 {
     Dependency_SqlIndex = new SqlIndexMultipleInfo {
         DataStructure = this.DataStructure, PropertyNames = this.PropertyNames
     };
     createdConcepts = new[] { Dependency_SqlIndex };
 }
Ejemplo n.º 3
0
        public IEnumerable<IConceptInfo> CreateNewConcepts(IEnumerable<IConceptInfo> existingConcepts)
        {
            var newConcepts = new List<IConceptInfo>();

            CheckSemantics(existingConcepts);

            var sqlIndex = new SqlIndexMultipleInfo { Entity = DataStructure, PropertyNames = PropertyNames };
            newConcepts.Add(sqlIndex);

            if (SqlImplementation(this))
            {
                var sqlUnique = new SqlUniqueMultipleInfo { SqlIndex = sqlIndex };
                newConcepts.Add(sqlUnique);
            }

            var properties = PropertyNames.Split(' ')
                .Select(name => new PropertyInfo { DataStructure = DataStructure, Name = name })
                .Select(property => new UniqueMultiplePropertyInfo { Unique = this, Property = property });
            newConcepts.AddRange(properties);

            return newConcepts;
        }
Ejemplo n.º 4
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);
        }
 public static bool IsSupported(SqlIndexMultipleInfo info)
 {
     return info.Entity is EntityInfo;
 }
Ejemplo n.º 6
0
 public void CheckSemantics(IEnumerable <IConceptInfo> concepts)
 {
     SqlIndexMultipleInfo.CheckIfSupported(Property.DataStructure, this);
 }