private bool CheckParentColumnsForForeignKey(
            Cell cell,
            IEnumerable <Cell> cells,
            AssociationEndMember parentEnd,
            ref List <ErrorLog.Record> errorList)
        {
            EntitySet entitySetAtEnd = MetadataHelper.GetEntitySetAtEnd((AssociationSet)cell.CQuery.Extent, parentEnd);

            if (ForeignConstraint.FindEntitySetForColumnsMappedToEntityKeys(cells, this.ParentColumns).Contains(entitySetAtEnd))
            {
                return(true);
            }
            if (errorList == null)
            {
                errorList = new List <ErrorLog.Record>();
            }
            ErrorLog.Record record = new ErrorLog.Record(ViewGenErrorCode.ForeignKeyParentTableNotMappedToEnd, Strings.ViewGen_Foreign_Key_ParentTable_NotMappedToEnd((object)this.ToUserString(), (object)this.ChildTable.Name, (object)cell.CQuery.Extent.Name, (object)parentEnd.Name, (object)this.ParentTable.Name, (object)entitySetAtEnd.Name), cell, string.Empty);
            errorList.Add(record);
            return(false);
        }
        private void GuaranteeMappedRelationshipForForeignKey(
            QueryRewriter childRewriter,
            QueryRewriter parentRewriter,
            IEnumerable <Cell> cells,
            ErrorLog errorLog,
            ConfigViewGenerator config)
        {
            ViewgenContext           viewgenContext1 = childRewriter.ViewgenContext;
            ViewgenContext           viewgenContext2 = parentRewriter.ViewgenContext;
            IEnumerable <MemberPath> keyFields       = ExtentKey.GetPrimaryKeyForEntityType(new MemberPath((EntitySetBase)this.ChildTable), this.ChildTable.ElementType).KeyFields;
            bool flag1 = false;
            bool flag2 = false;
            List <ErrorLog.Record> errorList = (List <ErrorLog.Record>)null;

            foreach (Cell cell in cells)
            {
                if (cell.SQuery.Extent.Equals((object)this.ChildTable))
                {
                    AssociationEndMember relationEndForColumns = ForeignConstraint.GetRelationEndForColumns(cell, this.ChildColumns);
                    if (relationEndForColumns == null || this.CheckParentColumnsForForeignKey(cell, cells, relationEndForColumns, ref errorList))
                    {
                        flag2 = true;
                        if (ForeignConstraint.GetRelationEndForColumns(cell, keyFields) != null && relationEndForColumns != null && ForeignConstraint.FindEntitySetForColumnsMappedToEntityKeys(cells, keyFields).Count > 0)
                        {
                            flag1 = true;
                            this.CheckConstraintWhenParentChildMapped(cell, errorLog, relationEndForColumns, config);
                            break;
                        }
                        if (relationEndForColumns != null)
                        {
                            AssociationSet extent = (AssociationSet)cell.CQuery.Extent;
                            MetadataHelper.GetEntitySetAtEnd(extent, relationEndForColumns);
                            flag1 = ForeignConstraint.CheckConstraintWhenOnlyParentMapped(extent, relationEndForColumns, childRewriter, parentRewriter);
                            if (flag1)
                            {
                                break;
                            }
                        }
                    }
                }
            }
            if (!flag2)
            {
                foreach (ErrorLog.Record record in errorList)
                {
                    errorLog.AddEntry(record);
                }
            }
            else
            {
                if (flag1)
                {
                    return;
                }
                string message = Strings.ViewGen_Foreign_Key_Missing_Relationship_Mapping((object)this.ToUserString());
                IEnumerable <LeftCellWrapper> wrappersFromContext1 = (IEnumerable <LeftCellWrapper>)ForeignConstraint.GetWrappersFromContext(viewgenContext2, (EntitySetBase)this.ParentTable);
                IEnumerable <LeftCellWrapper> wrappersFromContext2 = (IEnumerable <LeftCellWrapper>)ForeignConstraint.GetWrappersFromContext(viewgenContext1, (EntitySetBase)this.ChildTable);
                Set <LeftCellWrapper>         set = new Set <LeftCellWrapper>(wrappersFromContext1);
                set.AddRange(wrappersFromContext2);
                ErrorLog.Record record = new ErrorLog.Record(ViewGenErrorCode.ForeignKeyMissingRelationshipMapping, message, (IEnumerable <LeftCellWrapper>)set, string.Empty);
                errorLog.AddEntry(record);
            }
        }