Esempio n. 1
0
        /// <summary>
        /// Makes a shallow copy of the current DojoPromotionFlagCollection.
        /// as the parent object.
        /// </summary>
        /// <returns>DojoPromotionFlagCollection</returns>
        public DojoPromotionFlagCollection Clone()
        {
            DojoPromotionFlagCollection clonedDojoPromotionFlag = new DojoPromotionFlagCollection(count);

            lock (this)
            {
                foreach (DojoPromotionFlag item in this)
                {
                    clonedDojoPromotionFlag.Add(item);
                }
            }
            return(clonedDojoPromotionFlag);
        }
Esempio n. 2
0
        /// <summary>
        /// Makes a deep copy of the current DojoPromotionFlag.
        /// </summary>
        /// <param name="isolation">Placeholders are used to isolate the
        /// items in the DojoPromotionFlagCollection from their children.</param>
        public DojoPromotionFlagCollection Copy(bool isolated)
        {
            DojoPromotionFlagCollection isolatedCollection = new DojoPromotionFlagCollection(count);

            lock (this)
            {
                if (isolated)
                {
                    for (int i = 0; i < count; i++)
                    {
                        isolatedCollection.Add(DojoPromotionFlagArray[i].NewPlaceHolder());
                    }
                }
                else
                {
                    for (int i = 0; i < count; i++)
                    {
                        isolatedCollection.Add(DojoPromotionFlagArray[i].Copy());
                    }
                }
            }
            return(isolatedCollection);
        }
        private void cacheStoreCollection(int hashCode, DojoPromotionFlagCollection dojoPromotionFlagCollection)
        {
            CacheManager cache = CacheFactory.GetCacheManager();

            cache.Add(tableName + "_Collection_" + hashCode.ToString(), dojoPromotionFlagCollection);
        }
        public DojoPromotionFlagCollection GetCollection(int topCount, string whereClause, string sortClause)
        {
            StringBuilder query;
            Database      database;
            DbCommand     dbCommand;
            IDataReader   r;
            DojoPromotionFlagCollection dojoPromotionFlagCollection;
            int hashcode;

            // Cache Handling

            hashcode = 0;

            if (cacheEnabled)
            {
                hashcode = topCount.GetHashCode() +
                           whereClause.GetHashCode() +
                           sortClause.GetHashCode() +
                           tableName.GetHashCode();

                DojoPromotionFlagCollection collection = cacheFindCollection(hashcode);
                if (collection != null)
                {
                    return(collection);
                }
            }


            query = new StringBuilder("SELECT ");

            if (topCount > 0)
            {
                query.Append("TOP ");
                query.Append(topCount);
                query.Append(" ");
            }

            foreach (string columnName in InnerJoinFields)
            {
                query.Append("DojoPromotionFlag.");
                query.Append(columnName);
                query.Append(",");
            }

            //
            // Remove trailing comma
            //
            query.Length--;
            query.Append(" FROM kitTessen_PromotionFlags AS DojoPromotionFlag");
            //
            // Render where clause
            //
            if (whereClause != string.Empty)
            {
                query.Append(" WHERE ");
                query.Append(whereClause);
            }

            //
            // Render sort clause
            //
            if (sortClause != string.Empty)
            {
                query.Append(" ORDER BY ");
                query.Append(sortClause);
            }

            //
            // Render final semicolon
            //
            query.Append(";");
            database  = DatabaseFactory.CreateDatabase();
            dbCommand = database.GetSqlStringCommand(query.ToString());
                        #if DEBUG
            try
            {
                r = database.ExecuteReader(dbCommand);
            }
            catch (Exception e)
            {
                string msg = e.Message;
                throw(new Exception(msg + " --- Query: " + query.ToString()));
            }
                        #else
            r = database.ExecuteReader(dbCommand);
                        #endif

            dojoPromotionFlagCollection = new DojoPromotionFlagCollection();

            while (r.Read())
            {
                DojoPromotionFlag dojoPromotionFlag = ParseFromReader(r, 0, 1);

                dojoPromotionFlagCollection.Add(dojoPromotionFlag);
            }

            // Microsoft DAAB still needs to close readers.
            r.Close();

            if (cacheEnabled)
            {
                cacheStoreCollection(hashcode, dojoPromotionFlagCollection);
            }

            return(dojoPromotionFlagCollection);
        }