Exemple #1
0
    public override IQueryable GetQueryable(IQueryable source)
    {
        DateTime selectedValue = Calendar1.SelectedDate;

        if (Calendar1.SelectedDate.ToString().Contains("0001") && Calendar2.SelectedDate.ToString().Contains("0001"))
        {
            return(source);
        }

        if (!Calendar1.SelectedDate.ToString().Contains("0001") && !Calendar2.SelectedDate.ToString().Contains("0001"))
        {
            return(UtilsExpression.Set_IQueryableRange((typeof(DateTime)).Name,
                                                       Calendar1.SelectedDate.AddHours(int.Parse(ddlFromHour.SelectedValue)).ToString("yyyy-MM-dd HH:00:ss"),
                                                       Calendar2.SelectedDate.AddHours(int.Parse(ddlToHour.SelectedValue)).ToString("yyyy-MM-dd HH:00:ss")
                                                       , source.ElementType,
                                                       this.Column.Name,
                                                       ref source));
        }


        object value = selectedValue;

        //if(selectedValue == NullValueString) {
        //    value = null;
        //}
        //if(DefaultValues != null) {
        //    DefaultValues[Column.Name] = value;
        //}


        switch (DropDownList1.SelectedValue)

        {
        default:
            return(ApplyEqualityFilter(source, Column.Name, value));

            break;

        case "Greater":
        case "GreaterOrEqual":
        case "Equal":
        case "Less":
        case "LessOrEqual":
        case "==":
        case "=":
        case ">=":
        case "<=":
        case ">":
        case "<":
            return(UtilsExpression.Set_IQueryable((typeof(DateTime)).Name, selectedValue.AddHours(int.Parse(ddlFromHour.SelectedValue)).ToString("yyyy-MM-dd HH:00:00"), source.ElementType,
                                                  this.Column.Name, DropDownList1.SelectedValue,
                                                  ref source));
        }


        return(ApplyEqualityFilter(source, Column.Name, value));
    }
Exemple #2
0
    public override IQueryable GetQueryable(IQueryable source)
    {
        string selectedValue = TextBox1.Text;

        if (String.IsNullOrEmpty(selectedValue))
        {
            return(source);
        }
        object value = selectedValue;

        if (selectedValue == NullValueString)
        {
            value = null;
        }
        if (DefaultValues != null)
        {
            DefaultValues[Column.Name] = value;
        }

        switch (DropDownList1.SelectedValue)

        {
        default:
            return(ApplyEqualityFilter(source, Column.Name, value));

            break;

        case "Greater":
        case "GreaterOrEqual":
        case "Equal":
        case "Less":
        case "LessOrEqual":
        case "==":
        case "=":
        case ">=":
        case "<=":
        case ">":
        case "<": return(UtilsExpression.Set_IQueryable((typeof(Int64)).Name, selectedValue, source.ElementType,
                                                        this.Column.Name, DropDownList1.SelectedValue,
                                                        ref source));
        }

        return(ApplyEqualityFilter(source, Column.Name, value));
    }
Exemple #3
0
    public override IQueryable GetQueryable(IQueryable source)
    {
        string selectedValue = TextBox1.Text;

        if (String.IsNullOrEmpty(selectedValue))
        {
            return(source);
        }
        object value = selectedValue;

        if (selectedValue == NullValueString)
        {
            value = null;
        }
        if (DefaultValues != null)
        {
            DefaultValues[Column.Name] = value;
        }

        #region MyRegion working all
        //string selectedValue = TextBox1.Text;
        //if (String.IsNullOrEmpty(selectedValue))
        //{
        //    return source;
        //}
        //object value = selectedValue;
        //if (selectedValue == NullValueString)
        //{
        //    value = null;
        //}
        //if (DefaultValues != null)
        //{
        //    DefaultValues[Column.Name] = value;
        //}

        //int intCondition = int.Parse(selectedValue);
        //ConstantExpression intCondition_expression = Expression.Constant(intCondition);

        //ParameterExpression parameter = Expression.Parameter(source.ElementType);
        //MemberExpression property = Expression.Property(parameter, this.Column.Name);
        //if (Nullable.GetUnderlyingType(property.Type) != null)
        //{
        //    property = Expression.Property(property, "Value");
        //}

        //BinaryExpression comparison;

        //switch (DropDownList1.SelectedValue)

        //{

        //    default:
        //        return ApplyEqualityFilter(source, Column.Name, value);

        //        break;

        //    case "=":
        //        comparison = Expression.Equal(property, intCondition_expression);
        //        break;
        //    case ">=":

        //        comparison = Expression.GreaterThanOrEqual(property, intCondition_expression);

        //        break;
        //    case "<=":

        //        comparison = Expression.LessThanOrEqual(property, intCondition_expression);

        //        break;
        //    case ">":

        //        comparison = Expression.GreaterThan(property, intCondition_expression);

        //        break;
        //    case "<":

        //        comparison = Expression.LessThan(property, intCondition_expression);

        //        break;
        //}

        //LambdaExpression lambda = Expression.Lambda(comparison, parameter);

        //MethodCallExpression where = Expression.Call(
        //  typeof(Queryable),
        //  "Where",
        //  new Type[] { source.ElementType },
        //  new Expression[] { source.Expression, Expression.Quote(lambda) });

        //return source.Provider.CreateQuery(where);

        #endregion

        switch (DropDownList1.SelectedValue)

        {
        default:
            return(ApplyEqualityFilter(source, Column.Name, value));

            break;

        case "Greater":
        case "GreaterOrEqual":
        case "Equal":
        case "Less":
        case "LessOrEqual":
        case "==":
        case "=":
        case ">=":
        case "<=":
        case ">":
        case "<":
            return(UtilsExpression.Set_IQueryable((typeof(int)).Name, selectedValue, source.ElementType,
                                                  this.Column.Name, DropDownList1.SelectedValue,
                                                  ref source));
            //return UtilsExpression.Set_IQueryableRange((typeof(int)).Name, "0","5", source.ElementType,
            //                                            this.Column.Name, DropDownList1.SelectedValue,
            //                                            ref source);
        }
    }