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

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

            lock (this)
            {
                if (isolated)
                {
                    for (int i = 0; i < count; i++)
                    {
                        isolatedCollection.Add(DojoTestListStatusArray[i].NewPlaceHolder());
                    }
                }
                else
                {
                    for (int i = 0; i < count; i++)
                    {
                        isolatedCollection.Add(DojoTestListStatusArray[i].Copy());
                    }
                }
            }
            return(isolatedCollection);
        }
Exemplo n.º 3
0
        public DojoTestListStatusCollection GetCollection(int topCount, string whereClause, string sortClause, params DojoTestListStatusFlags[] optionFlags)
        {
            StringBuilder query;
            Database      database;
            DbCommand     dbCommand;
            IDataReader   r;
            DojoTestListStatusCollection dojoTestListStatusCollection;

            int innerJoinOffset;

            query = new StringBuilder("SELECT ");

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

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

            innerJoinOffset = InnerJoinFields.GetUpperBound(0) + 1;
            int onFinalizedOffset            = -1;
            int onFinalizedOnFinalizedOffset = -1;
            int onFinalizedOnCompletedOffset = -1;
            int onCompletedOffset            = -1;
            int onCompletedOnFinalizedOffset = -1;
            int onCompletedOnCompletedOffset = -1;

            //
            // Append Option Flag Fields
            //
            if (optionFlags != null)
            {
                for (int x = 0; x < optionFlags.Length; x++)
                {
                    switch (optionFlags[x])
                    {
                    case DojoTestListStatusFlags.OnFinalized:
                        for (int i = 0; i <= DojoTestListStatusManager.InnerJoinFields.GetUpperBound(0); i++)
                        {
                            query.Append("OnFinalized.");
                            query.Append(DojoTestListStatusManager.InnerJoinFields[i]);
                            query.Append(",");
                        }
                        onFinalizedOffset = innerJoinOffset;
                        innerJoinOffset   = onFinalizedOffset + DojoTestListStatusManager.InnerJoinFields.GetUpperBound(0) + 1;
                        break;

                    case DojoTestListStatusFlags.OnFinalizedOnFinalized:
                        for (int i = 0; i <= DojoTestListStatusManager.InnerJoinFields.GetUpperBound(0); i++)
                        {
                            query.Append("OnFinalized_OnFinalized.");
                            query.Append(DojoTestListStatusManager.InnerJoinFields[i]);
                            query.Append(",");
                        }
                        onFinalizedOnFinalizedOffset = innerJoinOffset;
                        innerJoinOffset = onFinalizedOnFinalizedOffset + DojoTestListStatusManager.InnerJoinFields.GetUpperBound(0) + 1;
                        break;

                    case DojoTestListStatusFlags.OnFinalizedOnCompleted:
                        for (int i = 0; i <= DojoTestListStatusManager.InnerJoinFields.GetUpperBound(0); i++)
                        {
                            query.Append("OnFinalized_OnCompleted.");
                            query.Append(DojoTestListStatusManager.InnerJoinFields[i]);
                            query.Append(",");
                        }
                        onFinalizedOnCompletedOffset = innerJoinOffset;
                        innerJoinOffset = onFinalizedOnCompletedOffset + DojoTestListStatusManager.InnerJoinFields.GetUpperBound(0) + 1;
                        break;

                    case DojoTestListStatusFlags.OnCompleted:
                        for (int i = 0; i <= DojoTestListStatusManager.InnerJoinFields.GetUpperBound(0); i++)
                        {
                            query.Append("OnCompleted.");
                            query.Append(DojoTestListStatusManager.InnerJoinFields[i]);
                            query.Append(",");
                        }
                        onCompletedOffset = innerJoinOffset;
                        innerJoinOffset   = onCompletedOffset + DojoTestListStatusManager.InnerJoinFields.GetUpperBound(0) + 1;
                        break;

                    case DojoTestListStatusFlags.OnCompletedOnFinalized:
                        for (int i = 0; i <= DojoTestListStatusManager.InnerJoinFields.GetUpperBound(0); i++)
                        {
                            query.Append("OnCompleted_OnFinalized.");
                            query.Append(DojoTestListStatusManager.InnerJoinFields[i]);
                            query.Append(",");
                        }
                        onCompletedOnFinalizedOffset = innerJoinOffset;
                        innerJoinOffset = onCompletedOnFinalizedOffset + DojoTestListStatusManager.InnerJoinFields.GetUpperBound(0) + 1;
                        break;

                    case DojoTestListStatusFlags.OnCompletedOnCompleted:
                        for (int i = 0; i <= DojoTestListStatusManager.InnerJoinFields.GetUpperBound(0); i++)
                        {
                            query.Append("OnCompleted_OnCompleted.");
                            query.Append(DojoTestListStatusManager.InnerJoinFields[i]);
                            query.Append(",");
                        }
                        onCompletedOnCompletedOffset = innerJoinOffset;
                        innerJoinOffset = onCompletedOnCompletedOffset + DojoTestListStatusManager.InnerJoinFields.GetUpperBound(0) + 1;
                        break;
                    }
                }
            }

            //
            // Remove trailing comma
            //
            query.Length--;
            if (optionFlags != null)
            {
                query.Append(" FROM ");

                //
                // Start INNER JOIN expressions
                //
                for (int x = 0; x < optionFlags.Length; x++)
                {
                    query.Append("(");
                }

                query.Append("kitTessen_DojoTestListStatuses AS DojoTestListStatus");
            }
            else
            {
                query.Append(" FROM kitTessen_DojoTestListStatuses AS DojoTestListStatus");
            }
            //
            // Finish INNER JOIN expressions
            //
            if (optionFlags != null)
            {
                for (int x = 0; x < optionFlags.Length; x++)
                {
                    switch (optionFlags[x])
                    {
                    case DojoTestListStatusFlags.OnFinalized:
                        query.Append(" LEFT JOIN kitTessen_DojoTestListStatuses AS OnFinalized ON DojoTestListStatus.OnFinalizedID = OnFinalized.DojoTestListStatusID)");
                        break;

                    case DojoTestListStatusFlags.OnFinalizedOnFinalized:
                        query.Append(" LEFT JOIN kitTessen_DojoTestListStatuses AS OnFinalized_OnFinalized ON OnFinalized.OnFinalizedID = OnFinalized_OnFinalized.DojoTestListStatusID)");
                        break;

                    case DojoTestListStatusFlags.OnFinalizedOnCompleted:
                        query.Append(" LEFT JOIN kitTessen_DojoTestListStatuses AS OnFinalized_OnCompleted ON OnFinalized.OnCompletedID = OnFinalized_OnCompleted.DojoTestListStatusID)");
                        break;

                    case DojoTestListStatusFlags.OnCompleted:
                        query.Append(" LEFT JOIN kitTessen_DojoTestListStatuses AS OnCompleted ON DojoTestListStatus.OnCompletedID = OnCompleted.DojoTestListStatusID)");
                        break;

                    case DojoTestListStatusFlags.OnCompletedOnFinalized:
                        query.Append(" LEFT JOIN kitTessen_DojoTestListStatuses AS OnCompleted_OnFinalized ON OnCompleted.OnFinalizedID = OnCompleted_OnFinalized.DojoTestListStatusID)");
                        break;

                    case DojoTestListStatusFlags.OnCompletedOnCompleted:
                        query.Append(" LEFT JOIN kitTessen_DojoTestListStatuses AS OnCompleted_OnCompleted ON OnCompleted.OnCompletedID = OnCompleted_OnCompleted.DojoTestListStatusID)");
                        break;
                    }
                }
            }

            //
            // 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

            dojoTestListStatusCollection = new DojoTestListStatusCollection();

            while (r.Read())
            {
                DojoTestListStatus dojoTestListStatus = ParseFromReader(r, 0, 1);

                // Fill OnFinalized
                if (onFinalizedOffset != -1 && !r.IsDBNull(onFinalizedOffset))
                {
                    DojoTestListStatusManager.FillFromReader(dojoTestListStatus.onFinalized, r, onFinalizedOffset, onFinalizedOffset + 1);

                    // Fill
                    if (onFinalizedOnFinalizedOffset != -1 && !r.IsDBNull(onFinalizedOnFinalizedOffset))
                    {
                        DojoTestListStatusManager.FillFromReader(dojoTestListStatus.onFinalized.OnFinalized, r, onFinalizedOnFinalizedOffset, onFinalizedOnFinalizedOffset + 1);
                    }

                    // Fill
                    if (onFinalizedOnCompletedOffset != -1 && !r.IsDBNull(onFinalizedOnCompletedOffset))
                    {
                        DojoTestListStatusManager.FillFromReader(dojoTestListStatus.onFinalized.OnCompleted, r, onFinalizedOnCompletedOffset, onFinalizedOnCompletedOffset + 1);
                    }
                }

                // Fill OnCompleted
                if (onCompletedOffset != -1 && !r.IsDBNull(onCompletedOffset))
                {
                    DojoTestListStatusManager.FillFromReader(dojoTestListStatus.onCompleted, r, onCompletedOffset, onCompletedOffset + 1);

                    // Fill
                    if (onCompletedOnFinalizedOffset != -1 && !r.IsDBNull(onCompletedOnFinalizedOffset))
                    {
                        DojoTestListStatusManager.FillFromReader(dojoTestListStatus.onCompleted.OnFinalized, r, onCompletedOnFinalizedOffset, onCompletedOnFinalizedOffset + 1);
                    }

                    // Fill
                    if (onCompletedOnCompletedOffset != -1 && !r.IsDBNull(onCompletedOnCompletedOffset))
                    {
                        DojoTestListStatusManager.FillFromReader(dojoTestListStatus.onCompleted.OnCompleted, r, onCompletedOnCompletedOffset, onCompletedOnCompletedOffset + 1);
                    }
                }

                dojoTestListStatusCollection.Add(dojoTestListStatus);
            }

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

            return(dojoTestListStatusCollection);
        }