Multiple FilterDescriptors throws exception

8 posts, 0 answers
  1. Tor
    Tor avatar
    9 posts
    Member since:
    Oct 2010

    Posted 15 Nov 2010 Link to this post

    We are building a custom AutoCompleteBox using the RadGridView control internally. We are binding the ItemsSource against a IQueryable(Of T) from NHibernate and using the CustomFilterDescriptor from this article.

    When using only one filter member it works:
    FilterDescriptor = New CustomFilterDescriptor({"Name"})

    But when using more than one, like this:
    FilterDescriptor = New CustomFilterDescriptor({"Name", "Number"})

    Throws an ArgumentException: An item with the same key has already been added.

    We are using the latest Q3 beta assemblies.
  2. Rossen Hristov
    Admin
    Rossen Hristov avatar
    2478 posts

    Posted 15 Nov 2010 Link to this post

    Hello Tor,

    How is that related to RadDataFilter?

    Can you please send us a sample project or at least the Stack Trace, since your description is quite concise and we can't understand what is going on.

    Thanks in advance.

    Best wishes,
    Ross
    the Telerik team
    See What's New in RadControls for WPF in Q3 2010 on Tuesday, November 16, 2010 11:00 AM - 12:00 PM EST or 10:00 PM - 11:00 PM EST: Register here>>
  3. UI for WPF is Visual Studio 2017 Ready
  4. Tor
    Tor avatar
    9 posts
    Member since:
    Oct 2010

    Posted 15 Nov 2010 Link to this post

    Hi Ross,

    I did not realize this forum was for the RadDataFilter control. We are actually using filtering on the RadGridView control.

    You can find the sample project to reproduce the error here. The stack trace is:

    at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)
    at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
    at System.Collections.Generic.Dictionary`2.Add(TKey key, TValue value)
    at NHibernate.Linq.Visitors.ExpressionParameterVisitor.VisitConstantExpression(ConstantExpression expression)
    at Remotion.Data.Linq.Parsing.ExpressionTreeVisitor.VisitExpression(Expression expression)
    at NHibernate.Linq.Visitors.NhExpressionTreeVisitor.VisitExpression(Expression expression)
    at Remotion.Data.Linq.Parsing.ExpressionTreeVisitor.VisitBinaryExpression(BinaryExpression expression)
    at Remotion.Data.Linq.Parsing.ExpressionTreeVisitor.VisitExpression(Expression expression)
    at NHibernate.Linq.Visitors.NhExpressionTreeVisitor.VisitExpression(Expression expression)
    at Remotion.Data.Linq.Parsing.ExpressionTreeVisitor.VisitBinaryExpression(BinaryExpression expression)
    at Remotion.Data.Linq.Parsing.ExpressionTreeVisitor.VisitExpression(Expression expression)
    at NHibernate.Linq.Visitors.NhExpressionTreeVisitor.VisitExpression(Expression expression)
    at Remotion.Data.Linq.Parsing.ExpressionTreeVisitor.VisitLambdaExpression(LambdaExpression expression)
    at Remotion.Data.Linq.Parsing.ExpressionTreeVisitor.VisitExpression(Expression expression)
    at NHibernate.Linq.Visitors.NhExpressionTreeVisitor.VisitExpression(Expression expression)
    at Remotion.Data.Linq.Parsing.ExpressionTreeVisitor.VisitUnaryExpression(UnaryExpression expression)
    at Remotion.Data.Linq.Parsing.ExpressionTreeVisitor.VisitExpression(Expression expression)
    at NHibernate.Linq.Visitors.NhExpressionTreeVisitor.VisitExpression(Expression expression)
    at Remotion.Data.Linq.Parsing.ExpressionTreeVisitor.VisitAndConvert[T](T expression, String methodName)
    at Remotion.Data.Linq.Parsing.ExpressionTreeVisitor.<>c__DisplayClass1`1.<VisitAndConvert>b__0(T expression)
    at Remotion.Data.Linq.Parsing.ExpressionTreeVisitor.VisitList[T](ReadOnlyCollection`1 list, Func`2 visitMethod)
    at Remotion.Data.Linq.Parsing.ExpressionTreeVisitor.VisitAndConvert[T](ReadOnlyCollection`1 expressions, String callerName)
    at Remotion.Data.Linq.Parsing.ExpressionTreeVisitor.VisitMethodCallExpression(MethodCallExpression expression)
    at Remotion.Data.Linq.Parsing.ExpressionTreeVisitor.VisitExpression(Expression expression)
    at NHibernate.Linq.Visitors.NhExpressionTreeVisitor.VisitExpression(Expression expression)
    at NHibernate.Linq.Visitors.ExpressionParameterVisitor.Visit(Expression expression)
    at NHibernate.Linq.NhLinqExpression..ctor(Expression expression)
    at NHibernate.Linq.NhQueryProvider.PrepareQuery(Expression expression, IQuery& query, NhLinqExpression& nhQuery)
    at NHibernate.Linq.NhQueryProvider.Execute(Expression expression)
    at Remotion.Data.Linq.QueryableBase`1.System.Collections.IEnumerable.GetEnumerator()
    at Telerik.Windows.Data.QueryableCollectionView.PopulateInternalList(IQueryable view)
    at Telerik.Windows.Data.QueryableCollectionView.CreateInternalList()
    at Telerik.Windows.Data.QueryableCollectionView.EnsureInternalList()
    at Telerik.Windows.Data.QueryableCollectionView.get_InternalList()
    at Telerik.Windows.Data.QueryableCollectionView.get_InternalCount()
    at Telerik.Windows.Data.QueryableCollectionView.get_IsEmpty()
    at Telerik.Windows.Data.QueryableCollectionView.InitializeCurrencyOnRefresh()
    at Telerik.Windows.Data.QueryableCollectionView.RefreshOverride()
    at Telerik.Windows.Data.QueryableCollectionView.RefreshInternal()
    at Telerik.Windows.Data.QueryableCollectionView.RefreshOrDefer()
    at Telerik.Windows.Data.QueryableCollectionView.InvalidatePagingAndRefresh()
    at Telerik.Windows.Data.QueryableCollectionView.OnFilterDescriptorsCollectionChanged(Object sender, NotifyCollectionChangedEventArgs e)
    at System.Collections.Specialized.NotifyCollectionChangedEventHandler.Invoke(Object sender, NotifyCollectionChangedEventArgs e)
    at System.Collections.ObjectModel.ObservableCollection`1.OnCollectionChanged(NotifyCollectionChangedEventArgs e)
    at Telerik.Windows.Data.RadObservableCollection`1.OnCollectionChanged(NotifyCollectionChangedEventArgs e)
    at Telerik.Windows.Data.ObservableItemCollection`1.OnCollectionChanged(NotifyCollectionChangedEventArgs e)
    at System.Collections.ObjectModel.ObservableCollection`1.OnCollectionChanged(NotifyCollectionChangedAction action, Object item, Int32 index)
    at System.Collections.ObjectModel.ObservableCollection`1.InsertItem(Int32 index, T item)
    at Telerik.Windows.Data.RadObservableCollection`1.InsertItem(Int32 index, T item)
    at System.Collections.ObjectModel.Collection`1.Add(T item)
    at System.Collections.ObjectModel.Collection`1.System.Collections.IList.Add(Object value)
    at Telerik.Windows.Data.CollectionHelper.Equalize(IList left, IList right, IEqualityComparer comparer)
    at Telerik.Windows.Data.CollectionHelper.Equalize(IList left, IList right)
    at Telerik.Windows.Data.DataItemCollection.EqualizeFilterDescriptors()
    at Telerik.Windows.Data.DataItemCollection.EqualizeDescriptors()
    at Telerik.Windows.Data.DataItemCollection.set_CollectionView(QueryableCollectionView value)
    at Telerik.Windows.Data.DataItemCollection.CreateCollectionView(IEnumerable source)
    at Telerik.Windows.Data.DataItemCollection.SetItemsSource(IEnumerable source)
    at Telerik.Windows.Controls.GridView.GridViewDataControl.<>c__DisplayClass18.<Bind>b__17()
    at Telerik.Windows.Controls.CursorManager.PerformTimeConsumingOperation(FrameworkElement frameworkElement, Action action)
    at Telerik.Windows.Controls.GridView.GridViewDataControl.Bind(Object newValue)
    at Telerik.Windows.Controls.GridView.GridViewDataControl.OnApplyTemplate()
    at System.Windows.FrameworkElement.ApplyTemplate()
    at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
    at System.Windows.UIElement.Measure(Size availableSize)
    at System.Windows.Controls.Border.MeasureOverride(Size constraint)
    at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
    at System.Windows.UIElement.Measure(Size availableSize)
    at System.Windows.Controls.Decorator.MeasureOverride(Size constraint)
    at System.Windows.Documents.AdornerDecorator.MeasureOverride(Size constraint)
    at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
    at System.Windows.UIElement.Measure(Size availableSize)
    at System.Windows.Controls.Decorator.MeasureOverride(Size constraint)
    at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
    at System.Windows.UIElement.Measure(Size availableSize)
    at System.Windows.Controls.Primitives.PopupRoot.MeasureOverride(Size constraint)
    at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
    at System.Windows.UIElement.Measure(Size availableSize)
    at System.Windows.Interop.HwndSource.SetLayoutSize()
    at System.Windows.Interop.HwndSource.set_RootVisualInternal(Visual value)
    at System.Windows.Controls.Primitives.Popup.SetRootVisualToPopupRoot()
    at System.Windows.Controls.Primitives.Popup.CreateWindow(Boolean asyncCall)
    at System.Windows.Controls.Primitives.Popup.OnIsOpenChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
    at System.Windows.DependencyObject.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
    at System.Windows.FrameworkElement.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
    at System.Windows.DependencyObject.NotifyPropertyChange(DependencyPropertyChangedEventArgs args)
    at System.Windows.DependencyObject.UpdateEffectiveValue(EntryIndex entryIndex, DependencyProperty dp, PropertyMetadata metadata, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, Boolean coerceWithDeferredReference, OperationType operationType)
    at System.Windows.DependencyObject.SetValueCommon(DependencyProperty dp, Object value, PropertyMetadata metadata, Boolean coerceWithDeferredReference, OperationType operationType, Boolean isInternal)
    at System.Windows.DependencyObject.SetValue(DependencyProperty dp, Object value)
    at System.Windows.Controls.Primitives.Popup.set_IsOpen(Boolean value)
    at WpfApplication2.Controls.AutoCompleteBoxUltimate.OnTextBoxKeyUp(Object sender, RoutedEventArgs e) in C:\Users\Hans\Documents\Expression\Blend 4\Projects\WpfApplication3\WpfApplication2\Code\AutoCompleteBoxUltimate.vb:line 106
    at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
    at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
    at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
    at System.Windows.UIElement.RaiseEvent(RoutedEventArgs args, Boolean trusted)
    at System.Windows.Input.InputManager.ProcessStagingArea()
    at System.Windows.Input.InputManager.ProcessInput(InputEventArgs input)
    at System.Windows.Input.InputProviderSite.ReportInput(InputReport inputReport)
    at System.Windows.Interop.HwndKeyboardInputProvider.ReportInput(IntPtr hwnd, InputMode mode, Int32 timestamp, RawKeyboardActions actions, Int32 scanCode, Boolean isExtendedKey, Boolean isSystemKey, Int32 virtualKey)
    at System.Windows.Interop.HwndKeyboardInputProvider.ProcessKeyAction(MSG& msg, Boolean& handled)
    at System.Windows.Interop.HwndSource.CriticalTranslateAccelerator(MSG& msg, ModifierKeys modifiers)
    at System.Windows.Interop.HwndSource.OnPreprocessMessage(Object param)
    at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Boolean isSingleParameter)
    at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler)
    at System.Windows.Threading.Dispatcher.InvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Boolean isSingleParameter)
    at System.Windows.Threading.Dispatcher.Invoke(DispatcherPriority priority, Delegate method, Object arg)
    at System.Windows.Interop.HwndSource.OnPreprocessMessageThunk(MSG& msg, Boolean& handled)
    at System.Windows.Interop.ComponentDispatcherThread.RaiseThreadMessage(MSG& msg)
    at System.Windows.Threading.Dispatcher.TranslateAndDispatchMessage(MSG& msg)
    at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
    at System.Windows.Application.RunInternal(Window window)
    at XamlGeneratedNamespace.GeneratedApplication.Main() in C:\Users\Hans\Documents\Expression\Blend 4\Projects\WpfApplication3\WpfApplication2\obj\Debug\App.g.vb:line 75
    at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
    at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
    at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
    at System.Threading.ThreadHelper.ThreadStart()
  5. Rossen Hristov
    Admin
    Rossen Hristov avatar
    2478 posts

    Posted 15 Nov 2010 Link to this post

    Hello Tor,

    The NHibernate NhExpressionTreeVisitor is throwing this exception for some reason. It appears that when it is visiting a ConstantExpression it is trying to add a dictionary entry with the same key for a second time.

    My suggestion is to post this exception on the NHibernate forums, since it originates from their code. Maybe the NHibernate folks can shed some light on this exception.

    Regards,
    Ross
    the Telerik team
    See What's New in RadControls for WPF in Q3 2010 on Tuesday, November 16, 2010 11:00 AM - 12:00 PM EST or 10:00 PM - 11:00 PM EST: Register here>>
  6. Tor
    Tor avatar
    9 posts
    Member since:
    Oct 2010

    Posted 16 Nov 2010 Link to this post

    There is probably some mismatch between Telerik's expression being built by the filter descriptors and NHibernate's Linq provider. I managed to get it working with the PredicateFilterDescriptor from this article.

    However when working with the VirtualQueryableCollectionView I get some very weird behaviour from the RadGridView, it does not apply filter correctly and sometimes does not refresh the grid view. Is this because it's still beta?
  7. Vlad
    Admin
    Vlad avatar
    11100 posts

    Posted 16 Nov 2010 Link to this post

    Hello Tor,

     Can you send us small example demonstrating this weird behavior?

    Regards,
    Vlad
    the Telerik team
    See What's New in RadControls for WPF in Q3 2010 on Tuesday, November 16, 2010 11:00 AM - 12:00 PM EST or 10:00 PM - 11:00 PM EST: Register here>>
  8. Tor
    Tor avatar
    9 posts
    Member since:
    Oct 2010

    Posted 16 Nov 2010 Link to this post

    Download the sample project from my previous post and change MainWindowModel.vb from:

    Public Sub New()
        Suppliers = New SupplierService().SuppliersQuery
    End Sub
     
    Public Property Suppliers As IQueryable(Of Supplier)

    to:

    Public Sub New()
        Suppliers = New VirtualQueryableCollectionView(New SupplierService().SuppliersQuery) With {.LoadSize = 20}
    End Sub
     
    Public Property Suppliers As VirtualQueryableCollectionView

    You might also have to change the connection string in SupplierService.vb.
  9. Vlad
    Admin
    Vlad avatar
    11100 posts

    Posted 19 Nov 2010 Link to this post

    Hello Tor,

     Unfortunately I'm unable to run the project since I don't have TelerikTest data-base. I'm not aware how filtering, sorting, etc. are implemented with NHibernate's Linq provider however we did not have such problems with EF and LINQ to SQL. Here is how the collection will apply filtering, sorting and paging to the query:

    SuppliersQuery.Where(this.FilterDescriptors).Sort(this.SortDescriptors).Skip(startIndex).Take(itemsCount)

    Nothing special as you can see. 

    Regards,
    Vlad
    the Telerik team
    Browse the videos here>> to help you get started with RadControls for WPF
Back to Top
UI for WPF is Visual Studio 2017 Ready