Beispiel #1
0
        internal override void LoadValueFromDb(object value, object exValue, LoadContext loadContext)
        {
            DataId              id                  = new DataId((string)DataProperty.EscapeFromDBNull(value));
            DataObject          dataObject          = (DataObject)null;
            DataObjectChildList dataObjectChildList = (DataObjectChildList)null;

            if (!id.IsEmpty)
            {
                MetadataAssociationRefList refs = this.Metadata.Association.Refs;
                MetadataAssociationRef     metadataAssociationRef = this.Metadata.Association.Selector == null ? refs[0] : refs.FindBySelectorValue(exValue);
                if (metadataAssociationRef == null)
                {
                    throw new DataException(string.Format("Нарушение целостности данных.\n{0}\nОшибка: Невозможно определить класс связанного объекта по значению селектора '{1}'.\n", (object)this.SystemView, exValue));
                }
                dataObject = this.Session[metadataAssociationRef.RefClass].EnsureCacheItem(id);
                if (dataObject.IsNull)
                {
                    dataObject = (DataObject)null;
                }
                else if (this.Metadata.IsAggregation)
                {
                    dataObjectChildList = dataObject.GetChilds(metadataAssociationRef.OwnerChildRef);
                    if ((loadContext & LoadContext.FetchAllObjects) != (LoadContext)0)
                    {
                        dataObjectChildList.SetCompleted(true);
                    }
                }
            }
            base.SetValue((object)dataObject);
            dataObjectChildList?.AttachChild(this.Object, true);
        }
        public DataProperty SelectSingleProperty(string path)
        {
            DataObject dataObject = this;
            int        startIndex = 0;

            while (true)
            {
                if (DataObject.Assigned(dataObject))
                {
                    int num = path.IndexOf('.', startIndex);
                    if (num >= 0)
                    {
                        string           memberName = path.Substring(startIndex, num - startIndex);
                        MetadataProperty property;
                        MetadataChildRef childRef;
                        dataObject.Class.NeedMember(memberName, out property, out childRef);
                        if (property != null)
                        {
                            dataObject = ((LinkProperty)dataObject[property]).Value;
                        }
                        else
                        {
                            DataObjectChildList childs = dataObject.GetChilds(childRef);
                            if (childs.Count != 0)
                            {
                                dataObject = childs[0];
                            }
                            else
                            {
                                goto label_6;
                            }
                        }
                        startIndex = num + 1;
                    }
                    else
                    {
                        goto label_9;
                    }
                }
                else
                {
                    break;
                }
            }
            return((DataProperty)null);

label_6:
            return((DataProperty)null);

label_9:
            if (startIndex > 0)
            {
                path = path.Substring(startIndex);
            }
            return(dataObject[path]);
        }
 private void CheckComplete()
 {
     if (this.FIsComplete)
     {
         return;
     }
     if (this.Object.IsNull)
     {
         this.FIsComplete = true;
     }
     else
     {
         DataStorage storage       = this.Object.Storage;
         DataSession masterSession = this.Session.MasterSession;
         if (masterSession != null)
         {
             DataObjectChildList childs      = masterSession[storage.Class][this.Object.Id].GetChilds(this.ChildRef);
             DataStorage         dataStorage = this.Session[this.ChildRef.ChildClass];
             MetadataProperty    property    = this.ChildRef.AggregationRef.Association.Property;
             for (int index = 0; index < childs.Count; ++index)
             {
                 DataObject untypedValue = (DataObject)dataStorage[childs[index].Id][property].UntypedValue;
             }
             this.FIsComplete = true;
         }
         else if (storage.IsChildListCompleted(this.ChildRef))
         {
             this.FIsComplete = true;
         }
         else
         {
             this.Session.TraceUnplannedChildrenLoading(this.ChildRef);
             LoadPlan plan = new LoadPlan(storage.Class);
             plan.EnsureChildRef(this.ChildRef, new LoadPlan(this.ChildRef.ChildClass));
             storage.Session.LoadData(plan, (DataObjectList)null, new DataId[1]
             {
                 this.Object.Id
             }, (string)null);
         }
     }
 }