/// <summary>
        /// Makes a shallow copy of the current DbContentStatusCollection.
        /// as the parent object.
        /// </summary>
        /// <returns>DbContentStatusCollection</returns>
        public DbContentStatusCollection Clone()
        {
            DbContentStatusCollection clonedDbContentStatus = new DbContentStatusCollection(count);

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

            lock (this)
            {
                if (isolated)
                {
                    for (int i = 0; i < count; i++)
                    {
                        isolatedCollection.Add(DbContentStatusArray[i].NewPlaceHolder());
                    }
                }
                else
                {
                    for (int i = 0; i < count; i++)
                    {
                        isolatedCollection.Add(DbContentStatusArray[i].Copy());
                    }
                }
            }
            return(isolatedCollection);
        }
示例#3
0
        public DbContentStatusCollection GetCollection(int topCount, string whereClause, string sortClause)
        {
            StringBuilder             query;
            Database                  database;
            DbCommand                 dbCommand;
            IDataReader               r;
            DbContentStatusCollection dbContentStatusCollection;


            query = new StringBuilder("SELECT ");

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

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

            //
            // Remove trailing comma
            //
            query.Length--;
            query.Append(" FROM kitCms_Statuses AS DbContentStatus");
            //
            // 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

            dbContentStatusCollection = new DbContentStatusCollection();

            while (r.Read())
            {
                DbContentStatus dbContentStatus = ParseFromReader(r, 0, 1);

                dbContentStatusCollection.Add(dbContentStatus);
            }

            return(dbContentStatusCollection);
        }