public DataObject GetObject(DataId id)
        {
            DataObject dataObject1 = this.EnsureCacheItem(id);

            if (dataObject1.IsUnknown)
            {
                DataSession masterSession = this.Session.MasterSession;
                if (masterSession != null)
                {
                    DataObject dataObject2 = masterSession[dataObject1.Class][id];
                    dataObject1.ClearSessionState();
                    if (dataObject2.IsError | dataObject2.IsDeleted)
                    {
                        dataObject1.IncludeSessionState(ObjectSessionState.Error);
                    }
                    else
                    {
                        dataObject1.IncludeSessionState(ObjectSessionState.Existing);
                    }
                }
                else
                {
                    dataObject1.LoadNotAssignedProperties();
                }
            }
            return(dataObject1);
        }
示例#2
0
 internal void Load(IDataReader reader, DataObjectList dstObjs, LoadContext loadContext)
 {
     object[] values = new object[reader.FieldCount];
     while (reader.Read())
     {
         reader.GetValues(values);
         DataId id = new DataId((string)values[0]);
         if (this.LoadedObjects[(object)id] == null)
         {
             DataObject dataObject = this.FStorage.EnsureCacheItem(id);
             if (!dataObject.IsDeleted)
             {
                 int index = 0;
                 int num   = 1;
                 for (; index < this.ObjectLoader.Count; ++index)
                 {
                     ObjectPartLoader objectPartLoader = this.ObjectLoader[index];
                     object           obj     = objectPartLoader.FieldName != null ? values[num++] : (object)null;
                     object           exValue = objectPartLoader.ExFieldName != null ? values[num++] : (object)null;
                     objectPartLoader.Load(dataObject, obj, exValue, loadContext);
                 }
                 dstObjs?.Add((object)dataObject);
             }
             this.LoadedObjects.Add((object)dataObject.Id, (object)dataObject);
             dataObject.IncludeSessionState(ObjectSessionState.Existing);
         }
     }
     if (loadContext != LoadContext.FetchAllObjects)
     {
         return;
     }
     for (int index1 = 0; index1 < this.ObjectLoader.Count; ++index1)
     {
         if (this.ObjectLoader[index1] is LinkPropertyLoader linkPropertyLoader && linkPropertyLoader.Association.Property.IsAggregation)
         {
             for (int index2 = 0; index2 < linkPropertyLoader.RefLoaders.Length; ++index2)
             {
                 MetadataClass cls = linkPropertyLoader.RefLoaders[index2].Class;
                 this.FStorage.Session[cls].CompleteChildLists(cls.Childs.Need(this.Class));
             }
         }
     }
 }