Beispiel #1
0
 protected override BaseNavigatorControl GetNavigatorControl()
 {
     if (NavigatorControl == null)
     {
         NavigatorControl = new MyProductActionsNavigatorControl {
             Url = Url
         }
     }
     ;
     return(NavigatorControl);
 }
Beispiel #2
0
        public override IQueryable SetFilters(IQueryable query)
        {
            FilterInitialize();
            foreach (var provider in filterProviders)
            {
                provider.IsSelect    = true;
                provider.Url         = Url;
                provider.ProjectName = "SampleDictionaries";
                provider.Init(typeof(MyProductAction));
                provider.SetFilters(ref query);
            }
            var filter = (IQueryable <MyProductAction>)query;

            //SetFilters(ref filter);
            query = filter;
            var enumerable = FilterByCustomExpressions((IQueryable <MyProductAction>)query);

            enumerable = FilterData(enumerable);

            if (ParentControl != null)
            {
                var param     = Expression.Parameter(typeof(MyProductAction), "r");
                var filterExp = ParentControl.GetExpression(FilterByParentControl, param);
                if (filterExp != null)
                {
                    Expression pred = Expression.Lambda(filterExp, param);
                    Expression expr = Expression.Call(typeof(Queryable), "Where", new[] { typeof(MyProductAction) }, enumerable.Expression, pred);
                    enumerable = (IQueryable <MyProductAction>)enumerable.Provider.CreateQuery(expr);
                }
                else
                {
                    string filterValue;
                    filterValue = ParentControl.SelectedValue == null
                                      ? "0"
                                      : ParentControl.SelectedValueLong.ToString();
                    enumerable = (IQueryable <MyProductAction>)
                                 LinqFilterGenerator.GenerateFilter(enumerable,
                                                                    typeof(MyProductAction),
                                                                    "Equal",
                                                                    FilterByParentControl,
                                                                    filterValue,
                                                                    null);
                }
            }

            IQueryable queryable = enumerable;

            if (ParentControl == null)
            {
                if (NavigatorControl == null)
                {
                    NavigatorControl = new MyProductActionsNavigatorControl {
                        Url = Url
                    }
                }
                ;
                queryable = NavigatorControl.FilterData(queryable);
                if (Url.UserControl != null && Url.UserControl.StartsWith("MyProductActions"))
                {
                    foreach (var queryParameter in Url.QueryParameters)
                    {
                        if (queryParameter.Key.Contains(".") && !string.IsNullOrEmpty(queryParameter.Value) && !queryParameter.Key.EndsWith(".id"))
                        {
                            queryable = LinqFilterGenerator.GenerateFilter(queryable, typeof(MyProductAction), "Equal",
                                                                           queryParameter.Key, queryParameter.Value, null);
                        }
                    }
                }
            }
            return((IQueryable <MyProductAction>)queryable);
        }