Exemple #1
0
        public void setupFilters()
        {
            collection = new ObservableCollection<NOS>()
            {
                new NOS( "Group1", "Item1" ),
                new NOS( "Group1", "Item2" ),
                new NOS( "Group1", "Item3" ),
                new NOS( "Group2", "Item4" ),
                new NOS( "Group2", "Item5" ),
                new NOS( "Group2", "Item6" ),
            };

            operation = new GroupByOperation<NOS, string>(new OperationContext(),
                Expression.Call(
                    typeof(Queryable).GetMethods()
                        .Where(i => i.Name == "GroupBy")
                        .Where(i => i.IsGenericMethodDefinition)
                        .Where(i => i.GetGenericArguments().Length == 2)
                        .Select(i => i.MakeGenericMethod(typeof(NOS), typeof(string)))
                        .Where(i => i.GetParameters().Length == 2)
                        .Where(i => i.GetParameters()[1].ParameterType == typeof(Expression<Func<NOS, string>>))
                        .Single(),
                    new ObservableQuery<NOS>(collection).Expression,
                    Expression.Lambda<Func<NOS, string>>(
                        Expression.MakeMemberAccess(
                            Expression.Parameter(typeof(NOS), "p"),
                            typeof(NOS).GetProperty("Value1")),
                        Expression.Parameter(typeof(NOS), "p"))));

            buffer = operation.AsObservableQuery().ToObservableView().ToBuffer();
        }