Exemple #1
0
 private bool IsDependentInOneToOneWith(EntityType entity, EntityType other)
 {
     return(entity.NavigationProperties.Any(p =>
                                            DependsOn(p, other) &&
                                            CodeGenerationHelper.GetAssociationType(p) == AssociationTypes.OneToOne &&
                                            CodeGenerationHelper.IsPrincipal(p)));
 }
Exemple #2
0
        /// <summary>
        /// BFS algorithm
        /// </summary>
        public IList <EntityType> GetPartialDependencyOrder(IList <EntityType> entities, out bool converged)
        {
            //Discard abstract entities
            //Consider entities to be treated with principal as done
            //Start with independent entities and consider them as done also
            IList <EntityType> abstractEntities             = CodeGenerationHelper.GetAbstractEntities(entities).ToList();
            IList <EntityType> entitiesToTreatWithPrincipal = GetEntitiesToTreatWithPrincipal(entities);
            IList <EntityType> discardedEntities            = abstractEntities.Concat(entitiesToTreatWithPrincipal).ToList();

            IList <EntityType> toTreatEntities = entities.Where(x => !discardedEntities.Contains(x)).ToList(); //missing some Diff operation...
            IList <EntityType> treatedEntities = new List <EntityType>();;

            //While not all entities are treated
            converged = true;
            int previousToTreatEntitiesCount = 0;

            do
            {
                if (previousToTreatEntitiesCount == toTreatEntities.Count)
                {
                    converged = false; //Algorithm cannot converge, check the model...
                    break;
                }
                previousToTreatEntitiesCount = toTreatEntities.Count;

                IList <EntityType> readyToTreatEntities = GetReadyToTreatEntities(discardedEntities, treatedEntities, toTreatEntities);

                treatedEntities = treatedEntities.Concat(readyToTreatEntities).ToList();
                toTreatEntities = toTreatEntities.Where(x => !treatedEntities.Contains(x)).ToList();
            } while (toTreatEntities.Count > 0);
            return(treatedEntities);
        }
Exemple #3
0
 private bool HasNonNavigableToOneLinkWith(EntityType entity, EntityType other)
 {
     return
         (entity.NavigationProperties.Any(p =>
                                          DependsOn(p, other) &&
                                          CodeGenerationHelper.Inverse(p) == null &&
                                          p.FromEndMember.RelationshipMultiplicity == RelationshipMultiplicity.One));
 }
Exemple #4
0
 public NonUniqueIndex GetNonUniqueIndexFor <T>(params string[] columns)
 {
     return(new NonUniqueIndex
     {
         TableName = CodeGenerationHelper.GetTableName <T>(),
         ColumnNames = columns.ToList()
     });
 }
Exemple #5
0
 private IList <EntityType> GetReadyToTreatEntities(IList <EntityType> discardedEntities, IList <EntityType> treatedEntities, IList <EntityType> toTreatEntities)
 {
     return(toTreatEntities
            .Where(x => x.NavigationProperties
                   .All(y => !CodeGenerationHelper.IsToOne(y) ||
                        discardedEntities.Contains(y.ToEndMember.GetEntityType()) ||
                        treatedEntities.Contains(y.ToEndMember.GetEntityType())))
            .OrderBy(x => x.Name)
            .ToList());
 }
Exemple #6
0
        public IList <EntityType> AllExceptIgnoredAbstractAndDerived()
        {
            var allButIgnored                = AllButIgnored();
            var abstractEntities             = CodeGenerationHelper.GetAbstractEntities(allButIgnored);
            IEnumerable <EntityType> derived = new List <EntityType>();

            foreach (var entity in abstractEntities)
            {
                derived = derived.Concat(CodeGenerationHelper.GetDerivedTypes(entity, allButIgnored));
            }

            return(allButIgnored
                   .Except(abstractEntities)
                   .Except(derived)
                   .ToList());
        }
Exemple #7
0
 public IList <EntityType> AllButIgnored()
 {
     return(entities_.Where(e => !CodeGenerationHelper.Ignore(e) && !CodeGenerationHelper.IgnoreButInterAssembly(e)).OrderBy(e => e.Name).ToList());
 }
Exemple #8
0
 private bool HasZeroOrOneToManyWithNoInverseWith(EntityType entity, EntityType other)
 {
     return(entity.NavigationProperties.Any(p => DependsOn(p, other) && CodeGenerationHelper.IsZeroOrOneToMany(p) && CodeGenerationHelper.Inverse(p) == null));
 }
Exemple #9
0
 private bool HasManyToManyAndIsGreaterLexicographicallyThan(EntityType entity, EntityType other)
 {
     return(entity.NavigationProperties.Any(p => DependsOn(p, other) && CodeGenerationHelper.IsManyToMany(p) && !CodeGenerationHelper.IsLexicographicallyOrdered(p)));
 }
Exemple #10
0
 private Table SmoTableFor <T>()
 {
     return(SmoDatabase.Tables[CodeGenerationHelper.GetTableName <T>()]);
 }