コード例 #1
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);
                }
            }
        }
コード例 #2
0
        private ListDictionary GetOriginalValues(
            string deletedId,
            InDbDatabase dbForOriginalValues)
        {
            ListDictionary properties = new ListDictionary();
            string         sql        = string.Format("SELECT * FROM [{0}] WHERE [{1}]=?", (object)this.Class.DataTable, (object)this.Class.IDProperty.DataField);

            using (InDbCommand command = dbForOriginalValues.CreateCommand(sql, DataType.String))
            {
                using (IDataReader originalValuesReader = command.ExecuteReader((object)deletedId))
                {
                    if (originalValuesReader.Read())
                    {
                        this.AddOriginalValues(properties, originalValuesReader);
                    }
                }
            }
            return(properties);
        }
コード例 #3
0
        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);
            }
        }
コード例 #4
0
        public Totals Execute()
        {
            ArrayList   arrayList  = new ArrayList();
            InDbCommand command    = this.FStorage.Session.Db.CreateCommand(this.FSql.ToString(), this.FSqlParamTypes);
            IDataReader dataReader = command.ExecuteReader(this.FSqlParamValues);

            try
            {
                while (dataReader.Read())
                {
                    object[] values = new object[dataReader.FieldCount];
                    dataReader.GetValues(values);
                    arrayList.Add((object)new Totals.Row(values));
                }
            }
            finally
            {
                dataReader.Dispose();
                command.Dispose();
            }
            return(new Totals((Totals.Row[])arrayList.ToArray(typeof(Totals.Row))));
        }