Example #1
0
 protected override BaseNavigatorControl GetNavigatorControl()
 {
     if (NavigatorControl == null)
     {
         NavigatorControl = new DIC_MyFirstDictionaryNavigatorControl {
             Url = Url
         }
     }
     ;
     return(NavigatorControl);
 }
Example #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(DIC_MyFirstDictionary));
                provider.SetFilters(ref query);
            }
            var filter = (IQueryable <DIC_MyFirstDictionary>)query;

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

            enumerable = FilterData(enumerable);

            if (ParentControl != null)
            {
                var param     = Expression.Parameter(typeof(DIC_MyFirstDictionary), "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(DIC_MyFirstDictionary) }, enumerable.Expression, pred);
                    enumerable = (IQueryable <DIC_MyFirstDictionary>)enumerable.Provider.CreateQuery(expr);
                }
                else
                {
                    string filterValue;
                    filterValue = ParentControl.SelectedValue == null
                                      ? "0"
                                      : ParentControl.SelectedValueLong.ToString();
                    enumerable = (IQueryable <DIC_MyFirstDictionary>)
                                 LinqFilterGenerator.GenerateFilter(enumerable,
                                                                    typeof(DIC_MyFirstDictionary),
                                                                    "Equal",
                                                                    FilterByParentControl,
                                                                    filterValue,
                                                                    null);
                }
            }

            IQueryable queryable = enumerable;

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