Esempio n. 1
0
        public void And()
        {
            SqlBoolean sqlTrue2  = new SqlBoolean(true);
            SqlBoolean sqlFalse2 = new SqlBoolean(false);

            // One result value
            SqlBoolean sqlResult;

            // true && false
            sqlResult = SqlBoolean.And(_sqlTrue, _sqlFalse);
            Assert.False(sqlResult.Value);
            sqlResult = SqlBoolean.And(_sqlFalse, _sqlTrue);
            Assert.False(sqlResult.Value);

            // true && true
            sqlResult = SqlBoolean.And(_sqlTrue, sqlTrue2);
            Assert.True(sqlResult.Value);

            sqlResult = SqlBoolean.And(_sqlTrue, _sqlTrue);
            Assert.True(sqlResult.Value);

            // false && false
            sqlResult = SqlBoolean.And(_sqlFalse, sqlFalse2);
            Assert.False(sqlResult.Value);
            sqlResult = SqlBoolean.And(_sqlFalse, _sqlFalse);
            Assert.False(sqlResult.Value);
        }
Esempio n. 2
0
        public void And()
        {
            SqlBoolean SqlTrue2  = new SqlBoolean(true);
            SqlBoolean SqlFalse2 = new SqlBoolean(false);

            // One result value
            SqlBoolean sqlResult;

            // true && false
            sqlResult = SqlBoolean.And(SqlTrue, SqlFalse);
            Assert.IsTrue(!sqlResult.Value, "And method does not work correctly (true && false)");
            sqlResult = SqlBoolean.And(SqlFalse, SqlTrue);
            Assert.IsTrue(!sqlResult.Value, "And method does not work correctly (false && true)");

            // true && true
            sqlResult = SqlBoolean.And(SqlTrue, SqlTrue2);
            Assert.IsTrue(sqlResult.Value, "And method does not work correctly (true && true)");

            sqlResult = SqlBoolean.And(SqlTrue, SqlTrue);
            Assert.IsTrue(sqlResult.Value, "And method does not work correctly (true && true2)");

            // false && false
            sqlResult = SqlBoolean.And(SqlFalse, SqlFalse2);
            Assert.IsTrue(!sqlResult.Value, "And method does not work correctly (false && false)");
            sqlResult = SqlBoolean.And(SqlFalse, SqlFalse);
            Assert.IsTrue(!sqlResult.Value, "And method does not work correctly (false && false2)");
        }
Esempio n. 3
0
        override public Object Aggregate(int[] records, AggregateType kind)
        {
            bool hasData = false;

            try {
                switch (kind)
                {
                case AggregateType.Min:
                    SqlBoolean min = true;
                    for (int i = 0; i < records.Length; i++)
                    {
                        int record = records[i];
                        if (IsNull(record))
                        {
                            continue;
                        }
                        min     = SqlBoolean.And(values[record], min);
                        hasData = true;
                    }
                    if (hasData)
                    {
                        return(min);
                    }
                    return(NullValue);

                case AggregateType.Max:
                    SqlBoolean max = false;
                    for (int i = 0; i < records.Length; i++)
                    {
                        int record = records[i];
                        if (IsNull(record))
                        {
                            continue;
                        }
                        max     = SqlBoolean.Or(values[record], max);
                        hasData = true;
                    }
                    if (hasData)
                    {
                        return(max);
                    }
                    return(NullValue);

                case AggregateType.First:
                    if (records.Length > 0)
                    {
                        return(values[records[0]]);
                    }
                    return(NullValue);

                case AggregateType.Count:
                    int count = 0;
                    for (int i = 0; i < records.Length; i++)
                    {
                        if (!IsNull(records[i]))
                        {
                            count++;
                        }
                    }
                    return(count);
                }
            }
            catch (OverflowException) {
                throw ExprException.Overflow(typeof(SqlBoolean));
            }
            throw ExceptionBuilder.AggregateException(kind, DataType);
        }
Esempio n. 4
0
        public override object Aggregate(int[] records, AggregateType kind)
        {
            bool flag = false;

            try
            {
                int        num;
                int        num2;
                int        num3;
                int        num4;
                SqlBoolean flag2;
                SqlBoolean flag3;
                int        num5;
                int        num6;
                switch (kind)
                {
                case AggregateType.Min:
                    flag3 = 1;
                    num3  = 0;
                    goto Label_0061;

                case AggregateType.Max:
                    flag2 = 0;
                    num2  = 0;
                    goto Label_00C1;

                case AggregateType.First:
                    if (records.Length <= 0)
                    {
                        return(base.NullValue);
                    }
                    return(this.values[records[0]]);

                case AggregateType.Count:
                    num4 = 0;
                    num  = 0;
                    goto Label_012A;

                default:
                    goto Label_014F;
                }
Label_0030:
                num6 = records[num3];
                if (!this.IsNull(num6))
                {
                    flag3 = SqlBoolean.And(this.values[num6], flag3);
                    flag  = true;
                }
                num3++;
Label_0061:
                if (num3 < records.Length)
                {
                    goto Label_0030;
                }
                if (flag)
                {
                    return(flag3);
                }
                return(base.NullValue);

Label_0090:
                num5 = records[num2];
                if (!this.IsNull(num5))
                {
                    flag2 = SqlBoolean.Or(this.values[num5], flag2);
                    flag  = true;
                }
                num2++;
Label_00C1:
                if (num2 < records.Length)
                {
                    goto Label_0090;
                }
                if (flag)
                {
                    return(flag2);
                }
                return(base.NullValue);

Label_0115:
                if (!this.IsNull(records[num]))
                {
                    num4++;
                }
                num++;
Label_012A:
                if (num < records.Length)
                {
                    goto Label_0115;
                }
                return(num4);
            }
            catch (OverflowException)
            {
                throw ExprException.Overflow(typeof(SqlBoolean));
            }
Label_014F:
            throw ExceptionBuilder.AggregateException(kind, base.DataType);
        }