Exemple #1
0
        public DataObjectList Query(LoadPlan loadPlan)
        {
            DataObjectList listInstance = this.CreateListInstance();

            this.Session.LoadData(loadPlan, listInstance, (DataId[])null, "");
            return(listInstance);
        }
Exemple #2
0
        public DataObjectList Query(LoadPlan loadPlan, params DataId[] ids)
        {
            DataObjectList listInstance = this.CreateListInstance();

            this.Session.LoadData(loadPlan, listInstance, ids, (string)null);
            return(listInstance);
        }
Exemple #3
0
 internal void Load(
     DataSession session,
     DataObjectList dstObjs,
     string condition,
     params object[] paramArray)
 {
     this.Load(session, dstObjs, (ObjectListLoader) new ObjectListLoaderByCondition(this.RootLoader, condition, paramArray));
 }
Exemple #4
0
        public DataObject QueryObject(LoadPlan loadPlan, DataId id)
        {
            DataObjectList listInstance = this.CreateListInstance();

            this.Session.LoadData(loadPlan, listInstance, new DataId[1]
            {
                id
            }, (string)null);
            return(listInstance.Count != 0 ? listInstance[0] : this.Session[loadPlan.Class].NullObject);
        }
Exemple #5
0
        internal override void Load(InDbDatabase db, DataObjectList dstObjs)
        {
            int count = this.FIds.Count;

            if (count == 0)
            {
                return;
            }
            DataId[] dataIdArray = new DataId[count];
            this.FIds.Keys.CopyTo((Array)dataIdArray, 0);
            this.FIds.Clear();
            StringBuilder stringBuilder = new StringBuilder(this.SelectSql);

            stringBuilder.Append(" WHERE [").Append(this.InProperty.DataField).Append("] IN ('");
            int length = stringBuilder.Length;
            int index1 = 0;

            while (index1 < count)
            {
                stringBuilder.Length = length;
                for (int index2 = 0; index1 < count && index2 < 100; ++index2)
                {
                    if (index2 > 0)
                    {
                        stringBuilder.Append("','");
                    }
                    stringBuilder.Append(dataIdArray[index1].ToString());
                    ++index1;
                }
                stringBuilder.Append("')");
                InDbCommand command = db.CreateCommand(stringBuilder.ToString());
                IDataReader reader  = command.ExecuteReader();
                try
                {
                    this.Load(reader, dstObjs, (LoadContext)0);
                }
                finally
                {
                    reader.Dispose();
                    command.Dispose();
                }
            }
            if (!this.InProperty.IsId)
            {
                return;
            }
            for (int index2 = 0; index2 < count; ++index2)
            {
                DataId id = dataIdArray[index2];
                if (!this.LoadedObjects.ContainsKey((object)id))
                {
                    this.FStorage.EnsureCacheItem(id).SetSessionState(ObjectSessionState.Error);
                }
            }
        }
Exemple #6
0
        public DataObjectList Query(
            LoadPlan loadPlan,
            string condition,
            params object[] paramArray)
        {
            DataObjectList listInstance = this.CreateListInstance();

            this.Session.TraceQueryStarted(this.Class);
            this.Session.LoadData(loadPlan, listInstance, (DataId[])null, condition, paramArray);
            this.Session.TraceQueryFinished();
            return(listInstance);
        }
Exemple #7
0
 private void Load(DataSession session, DataObjectList dstObjs, ObjectListLoader listLoader)
 {
     listLoader.FStorage = session[listLoader.Class];
     for (int index = 0; index < this.ObjectListLoaders.Count; ++index)
     {
         ObjectListLoader objectListLoader = this.ObjectListLoaders[index];
         objectListLoader.FStorage = session[objectListLoader.Class];
     }
     do
     {
         listLoader.Load(session.Db, dstObjs);
         for (int index = 0; index < this.ObjectListLoaders.Count; ++index)
         {
             this.ObjectListLoaders[index].Load(session.Db, (DataObjectList)null);
         }
     }while (this.HasUnloadedObjects);
 }
Exemple #8
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));
             }
         }
     }
 }
        internal override void Load(InDbDatabase db, DataObjectList dstObjs)
        {
            StringBuilder sql     = new StringBuilder();
            bool          onePass = true;

            if (this.Condition.Length == 0)
            {
                sql.Append(this.SelectSql);
            }
            else
            {
                this.GenerateLoadSql(sql, ref onePass);
            }
            if (onePass || this.ObjectLoader.Count == 0)
            {
                using (InDbCommand command = db.CreateCommand(sql.ToString(), this.FParamTypes))
                {
                    using (IDataReader reader = command.ExecuteReader(this.FParamValues))
                    {
                        LoadContext loadContext = this.Condition == string.Empty ? LoadContext.FetchAllObjects : (LoadContext)0;
                        this.Load(reader, dstObjs, loadContext);
                    }
                }
            }
            else
            {
                List <DataId> dataIdList = new List <DataId>();
                using (InDbCommand command = db.CreateCommand(sql.ToString(), this.FParamTypes))
                {
                    using (IDataReader dataReader = command.ExecuteReader(this.FParamValues))
                    {
                        while (dataReader.Read())
                        {
                            dataIdList.Add(new DataId(dataReader.GetString(0)));
                        }
                    }
                }
                this.FStorage.Session.LoadData(this.ObjectLoader.BasePlan, dstObjs, dataIdList.ToArray(), (string)null);
            }
        }
 public void Delete()
 {
     if (this.SessionStateContainsAny(ObjectSessionState.Error | ObjectSessionState.NullObject))
     {
         this.InvalidStateForOperation("Ошибка удаления объекта.");
     }
     if (this.IsDeleted)
     {
         return;
     }
     this.RemoveFromChildLists(true);
     for (int index1 = 0; index1 < this.Class.Childs.Count; ++index1)
     {
         DataObjectList dataObjectList = new DataObjectList((ICollection)this.GetChilds(this.Class.Childs[index1]));
         for (int index2 = dataObjectList.Count - 1; index2 >= 0; --index2)
         {
             dataObjectList[index2].Delete();
         }
     }
     this.Attachments.DeleteAll();
     this.Storage.EnqueueObjectForUpdate(this);
     this.IncludeSessionState(ObjectSessionState.Deleted);
 }
        public override object GetValue(DataObject obj)
        {
            DataObjectList dataObjectList1 = new DataObjectList();

            dataObjectList1.Add((object)obj);
            DataObjectList dataObjectList2 = dataObjectList1;

            foreach (Navigator navigator in this.FNavigation)
            {
                DataObjectList navigableObjects = new DataObjectList();
                foreach (DataObject sourceObject in (ArrayList)dataObjectList2)
                {
                    navigator.GetNavigableObjects(sourceObject, navigableObjects);
                }
                dataObjectList2 = navigableObjects;
            }
            List <object> values = new List <object>();

            foreach (DataObject dataObject in (ArrayList)dataObjectList2)
            {
                values.Add(this.FMemberValueGetter.GetValue(dataObject));
            }
            return(this.FValueCardinality.GetValue(values));
        }
Exemple #12
0
 public abstract void GetNavigableObjects(
     DataObject sourceObject,
     DataObjectList navigableObjects);
Exemple #13
0
 internal abstract void Load(InDbDatabase connection, DataObjectList dstObjs);
Exemple #14
0
 internal void Load(DataSession session, DataObjectList dstObjs, DataId[] ids) => this.Load(session, dstObjs, (ObjectListLoader) new ObjectListLoaderByIds(this.RootLoader, this.RootLoader.BasePlan.Class.IDProperty, ids));