Esempio n. 1
0
        public IRelationshipList FindItems(RelationSearchField searchField, string searchFor)
        {
            var list = new RelationshipList();

            foreach (var item in this)
            {
                if ((searchField == RelationSearchField.ToTableName) && (item.ToTableName == searchFor))
                {
                    list.Add(item);
                }
                else if ((searchField == RelationSearchField.ToColumnName) && (item.ToColumnName == searchFor))
                {
                    list.Add(item);
                }
                else if ((searchField == RelationSearchField.ToFieldName) && (item.ToFieldName == searchFor))
                {
                    list.Add(item);
                }
                else if ((searchField == RelationSearchField.FromTableName) && (item.FromTableName == searchFor))
                {
                    list.Add(item);
                }
                else if ((searchField == RelationSearchField.FromFieldName) && (item.FromFieldName == searchFor))
                {
                    list.Add(item);
                }
                else if ((searchField == RelationSearchField.FromColumnName) && (item.FromColumnName == searchFor))
                {
                    list.Add(item);
                }
            }
            return(list);
        }
Esempio n. 2
0
        public IRelationshipList Fetch(RelationshipMultiplicityType TypeToFetch)
        {
            var retListRaw = new List <IRelationship>();

            if (TypeToFetch == RelationshipMultiplicityType.OneToMany)
            {
                retListRaw = this.Where(r => r.Type == "One to Many").ToList();
            }
            else if (TypeToFetch == RelationshipMultiplicityType.ZeroOrOneToMany)
            {
                retListRaw = this.Where(r => ((r.Type == "One to Many") || (r.Type == "ZeroOrOne to Many"))).ToList();
            }
            else if (TypeToFetch == RelationshipMultiplicityType.ManyToOne)
            {
                retListRaw = this.Where(r => r.Type == "Many to One").ToList();
            }
            else if (TypeToFetch == RelationshipMultiplicityType.ManyToZeroOrOne)
            {
                retListRaw = this.Where(r => ((r.Type == "Many to ZeroOrOne") || (r.Type == "Many to One"))).ToList();
            }
            else if (TypeToFetch == RelationshipMultiplicityType.OneToOne)
            {
                retListRaw = this.Where(r => (r.Type == "One to One")).ToList();
            }
            else if (TypeToFetch == RelationshipMultiplicityType.OneToZeroOrOne)
            {
                retListRaw = this.Where(r => ((r.Type == "One to ZeroOrOne") || (r.Type == "One to One"))).ToList();
            }
            else if (TypeToFetch == RelationshipMultiplicityType.ZeroOrOneToOne)
            {
                retListRaw = this.Where(r => ((r.Type == "ZeroOrOne to One") || (r.Type == "One to One"))).ToList();
            }

            var retList = new RelationshipList();

            if (retListRaw.Count > 0)
            {
                //this should sort equal field names before non equal field names,  this will handle relationship with duplicate names correctly
                foreach (var item in retListRaw)
                {
                    if (item.ToFieldName.Equals(item.FromFieldName))
                    {
                        retList.Add(item);
                    }
                }
                foreach (var item in retListRaw)
                {
                    if (!item.ToFieldName.Equals(item.FromFieldName))
                    {
                        retList.Add(item);
                    }
                }
            }

            return(retList);
        }