Example #1
0
 private Boolean NullAllowedAndPresent(EntityMetaData.OutboundReferences foreignKeyMD, object[] foreignKeyValues)
 {
     if (foreignKeyMD.Nullable)
     {
         foreach (var value in foreignKeyValues)
         {
             if (value == null)
             {
                 return(true);
             }
         }
         return(false);
     }
     return(false);
 }
Example #2
0
 private Boolean CheckMetaDataArguments(EntityMetaData.OutboundReferences foreignKeyMD)
 {
     if (foreignKeyMD.foreignKeyProperties == null)
     {
         return(false);
     }
     if (foreignKeyMD.foreignKeyProperties.Count != foreignKeyMD.foreignKeyProjectionProperties.Count)
     {
         throw new DataMisalignedException("Metadata content error.");
     }
     if (foreignKeyMD.foreignKeyProperties.Count == 0)
     {
         throw new ArgumentOutOfRangeException("Metadata content error.");
     }
     return(true);
 }
Example #3
0
        private List <EntityMetaData> SetDependencyInfoViaAssociations(List <EntityMetaData> entities, List <AssociationType> assocInContext)
        {
            EntityMetaData.OutboundReferences dep = null;
            foreach (var association in assocInContext)
            {
                foreach (var reference in association.ReferentialConstraints)
                {
                    var currentEntity   = LookUp(entities, reference.FromProperties.First().DeclaringType);
                    var dependentEntity = LookUp(entities, reference.ToProperties.First().DeclaringType);
                    dep = SetForeignKeyInfo(currentEntity,
                                            dependentEntity,
                                            reference.FromProperties.ToList(),
                                            reference.ToProperties.ToList(),
                                            reference.FromRole.DeleteBehavior,
                                            reference.ToRole.RelationshipMultiplicity);
                    if (dep != null)
                    {
                        if (currentEntity.outRefs == null)
                        {
                            currentEntity.outRefs = new List <EntityMetaData.OutboundReferences>();
                        }
                        currentEntity.outRefs.Add(dep);
                    }

                    dep = SetForeignKeyInfo(dependentEntity,
                                            currentEntity,
                                            reference.ToProperties.ToList(),
                                            reference.FromProperties.ToList(),
                                            reference.ToRole.DeleteBehavior,
                                            reference.FromRole.RelationshipMultiplicity);
                    if (dep != null)
                    {
                        if (dependentEntity.outRefs == null)
                        {
                            dependentEntity.outRefs = new List <EntityMetaData.OutboundReferences>();
                        }
                        dependentEntity.outRefs.Add(dep);
                    }
                }
            }
            return(entities);
        }
Example #4
0
 private void LogRef(EdmType source, EntityMetaData.OutboundReferences references, String methodNameStr)
 {
     if (references == null)
     {
         throw new NoNullAllowedException("Unexpected Null pointer");
     }
     logger.Log(LogLevel.Info, $"{methodNameStr}:  ");
     logger.Log(LogLevel.Info, $"{methodNameStr}: The referred entity is: {references.referredEntity.entity.Name}  ");
     foreach (var prop in references.foreignKeyProperties)
     {
         logger.Log(LogLevel.Info, $"{methodNameStr}:     with foreignkey property: {source.Name} : {prop.Name}  ");
     }
     foreach (var prop in references.foreignKeyProjectionProperties)
     {
         logger.Log(LogLevel.Info, $"{methodNameStr}:     Corresponding with  {references.referredEntity.entity.Name} : {prop.Name}  ");
     }
     logger.Log(LogLevel.Info, $"{methodNameStr}: Multiplicity: {references.multiplicity.ToString()}  ");
     logger.Log(LogLevel.Info, $"{methodNameStr}: Delete behavior: {references.deleteBehavior.ToString()}  ");
     logger.Log(LogLevel.Info, $"{methodNameStr}: Nulls Allowed: {references.Nullable.ToString()}  ");
     logger.Log(LogLevel.Info, $"{methodNameStr}:  ");
 }