Beispiel #1
0
        private void InitRelations()
        {
            foreach (var field in this.Fields)
            {
                var fieldInfo = field.Value;

                if (fieldInfo.Type == FieldType.ObjectLink)
                {
                    var childE = EntityMetaData.Get(fieldInfo.RefObject);
                    var rel    = new EntityRelation(EntityRelationType.ManyToOne, this.EntityId, fieldInfo.RefObject, fieldInfo, null, childE.GetFieldSchema(childE.TextField));
                    this.Relations.Add(rel);
                }
                if (fieldInfo.Type == FieldType.MultiObjectLink)
                {
                    var childE = EntityMetaData.Get(fieldInfo.RefObject);
                    var rel    = new EntityRelation(EntityRelationType.ManyToMany, this.EntityId, fieldInfo.RefObject, fieldInfo, null, childE.GetFieldSchema(childE.TextField));
                    this.Relations.Add(rel);
                }
                else if (fieldInfo.Type == FieldType.OneToMany)
                {
                    var relField = (OneToManyField)fieldInfo;
                    var childE   = EntityMetaData.Get(relField.RefObject);
                    var rel      = new EntityRelation(EntityRelationType.OneToMany, this.EntityId, relField.RefObject, fieldInfo, childE.GetFieldSchema(relField.RefFieldName), null);
                    this.Relations.Add(rel);
                }
                // else if (fieldInfo.Type == FieldType.OneToOne)
                // {
                //     var relField = (OneToManyField)fieldInfo;
                //     var childE = EntityMetaData.Get(relField.RefObject);
                //     var rel = new EntityRelation(EntityRelationType.OneToMany, this.EntityId, relField.RefObject, fieldInfo, childE.GetFieldSchema(relField.RefFieldName), null);
                //     this.Relations.Add(rel);
                // }
            }
        }
Beispiel #2
0
 protected void BuildRelatedFIeldQueries(EntityQueryBuilder qBuilder)
 {
     _relatedFieldDataQryList = new InvariantDictionary <string>();
     foreach (var rel in this.Relations)
     {
         if (rel.Type == EntityRelationType.ManyToMany)
         {
             var childE = EntityMetaData.Get(rel.ChildName);
             _relatedFieldDataQryList.Add(rel.ParentRefField.Name, qBuilder.PrepareRelatedFieldDataQueries(rel, childE));
         }
     }
 }