Beispiel #1
0
        public wDBRowCollection Where(string what, ComparisonOperator op, object operand)
        {
            string operandTwo = "";
            if (operand is int)
                operandTwo = ((int)operand).ToString();
            else if (operand is string)
                operandTwo = (string)operand;
            else if (operand is bool)
                operandTwo = ((bool)operand) ? "1" : "0";

            wDBRowCollection newCollection = new wDBRowCollection();
            for (int i = 0; i < this.rows.Count; i++)
            {
                string operandOne = this.rows[i][what];
                double opOne = 0, opTwo = 0;
                double.TryParse(operandOne, out opOne);
                double.TryParse(operandTwo, out opTwo);
                switch(op)
                {
                    case ComparisonOperator.Is:
                        if(operandOne == operandTwo)
                            newCollection.rows.Add(this.rows[i]);
                        break;
                    case ComparisonOperator.IsNot:
                        if(operandOne != operandTwo)
                            newCollection.rows.Add(this.rows[i]);
                        break;
                    case ComparisonOperator.LessThan:
                        if(opOne < opTwo)
                            newCollection.rows.Add(this.rows[i]);
                        break;
                    case ComparisonOperator.LessThanEqualTo:
                        if(opOne <= opTwo)
                            newCollection.rows.Add(this.rows[i]);
                        break;
                    case ComparisonOperator.GreaterThan:
                        if(opOne > opTwo)
                            newCollection.rows.Add(this.rows[i]);
                        break;
                    case ComparisonOperator.GreaterThanEqualTo:
                        if(opOne >= opTwo)
                            newCollection.rows.Add(this.rows[i]);
                        break;
                    case ComparisonOperator.StartsWith:
                    {
                        if (operandOne.StartsWith(operandTwo))
                        {
                            newCollection.rows.Add(this.rows[i]);
                        }
                        break;
                    }
                }                    
            }
            return newCollection;
        }
Beispiel #2
0
        public wDBRowCollection Where(string what, ComparisonOperator op, object operand)
        {
            string operandTwo = "";

            if (operand is int)
            {
                operandTwo = ((int)operand).ToString();
            }
            else if (operand is string)
            {
                operandTwo = (string)operand;
            }
            else if (operand is bool)
            {
                operandTwo = ((bool)operand) ? "1" : "0";
            }

            wDBRowCollection newCollection = new wDBRowCollection();

            for (int i = 0; i < this.rows.Count; i++)
            {
                string operandOne = this.rows[i][what];
                double opOne = 0, opTwo = 0;
                double.TryParse(operandOne, out opOne);
                double.TryParse(operandTwo, out opTwo);
                switch (op)
                {
                case ComparisonOperator.Is:
                    if (operandOne == operandTwo)
                    {
                        newCollection.rows.Add(this.rows[i]);
                    }
                    break;

                case ComparisonOperator.IsNot:
                    if (operandOne != operandTwo)
                    {
                        newCollection.rows.Add(this.rows[i]);
                    }
                    break;

                case ComparisonOperator.LessThan:
                    if (opOne < opTwo)
                    {
                        newCollection.rows.Add(this.rows[i]);
                    }
                    break;

                case ComparisonOperator.LessThanEqualTo:
                    if (opOne <= opTwo)
                    {
                        newCollection.rows.Add(this.rows[i]);
                    }
                    break;

                case ComparisonOperator.GreaterThan:
                    if (opOne > opTwo)
                    {
                        newCollection.rows.Add(this.rows[i]);
                    }
                    break;

                case ComparisonOperator.GreaterThanEqualTo:
                    if (opOne >= opTwo)
                    {
                        newCollection.rows.Add(this.rows[i]);
                    }
                    break;

                case ComparisonOperator.StartsWith:
                {
                    if (operandOne.StartsWith(operandTwo))
                    {
                        newCollection.rows.Add(this.rows[i]);
                    }
                    break;
                }
                }
            }
            return(newCollection);
        }