public DateTimeCategory(string name, DateTimeIntervalStruct[] value)
 {
     Name = name;
     Value = value;
 }
        private void insertValueInterval(int categoryID, DateTimeIntervalStruct intervalStruct)
        {
            int leftCategoryValueID;
            int rightCategoryValueID;
            BoundaryEnum leftBracketType;
            BoundaryEnum rightBracketType;

            if (intervalStruct.leftBoundType == BoundaryEnum.Infinity)
            {
                leftCategoryValueID = SetValue(InfinityTypeEnum.MinusInfinity);
                leftBracketType = BoundaryEnum.Round;
            }
            else
            {
                leftCategoryValueID = SetValue(intervalStruct.leftBound);
                leftBracketType = intervalStruct.leftBoundType;
            }
            if (intervalStruct.rightBoundType == BoundaryEnum.Infinity)
            {
                rightCategoryValueID = SetValue(intervalStruct.leftBound);
                rightBracketType = BoundaryEnum.Round;
            }
            else
            {
                rightCategoryValueID = SetValue(intervalStruct.rightBound);
                rightBracketType = intervalStruct.rightBoundType;
            }
            this.SetCategoryInterval(
                categoryID,
                leftCategoryValueID,
                rightCategoryValueID,
                leftBracketType,
                rightBracketType);
        }
        /// <summary>
        /// Method which composes WHERE clause for a category of the DateTimeInterval type.
        /// </summary>
        /// <param name="dateTimeInterval">Category of dateTime interval type</param>
        /// <param name="columnSelectExpression">Column select expression</param>
        /// <returns>WHERE clause</returns>
        private String GetWhereClauseDateTime(DateTimeIntervalStruct[] dateTimeIntervalSeq, String columnSelectExpression)
        {
            StringBuilder returnString = new StringBuilder();

            bool first = true;

            foreach (DateTimeIntervalStruct dateTimeInterval in dateTimeIntervalSeq)
            {
                if (first)
                {
                    first = false;
                    returnString.Append("(");
                }
                else
                {
                    returnString.Append(" OR(");
                }

                //if both bounds are infinity, no restriction is needed
                if ((dateTimeInterval.leftBoundType == BoundaryEnum.Infinity) && (dateTimeInterval.rightBoundType == BoundaryEnum.Infinity))
                    return "";

                returnString.Append(columnSelectExpression);
                bool left = false;

                if (dateTimeInterval.leftBoundType == BoundaryEnum.Round)
                {

                    returnString.Append(" > " + dateTimeInterval.leftBound);
                    left = true;
                }
                else
                {
                    if (dateTimeInterval.leftBoundType == BoundaryEnum.Sharp)
                    {

                        returnString.Append(" >= " + dateTimeInterval.leftBound);
                        left = true;
                    }
                    //Infinity is left, no restriction needed
                }

                if (dateTimeInterval.rightBoundType == BoundaryEnum.Round)
                {
                    if (left)
                    {

                        returnString.Append(" AND " + columnSelectExpression);
                    }

                    returnString.Append(" < " + dateTimeInterval.rightBound);
                }
                else
                {
                    if (dateTimeInterval.rightBoundType == BoundaryEnum.Sharp)
                    {
                        if (left)
                        {

                            returnString.Append(" AND " + columnSelectExpression);
                        }

                        returnString.Append(" <= " + dateTimeInterval.rightBound);
                    }
                    //Infinity is left, no restriction needed
                }

                returnString.Append(")");
            }
            return returnString.ToString();
        }