Exception while filtering enum columns. (Auto-generated gridView)

6 posts, 0 answers
  1. Babken
    Babken avatar
    2 posts
    Member since:
    Feb 2017

    Posted 02 Aug Link to this post

    Hi.

    I'm considering the purchase of UI for WPF, so I downloaded to test the trial version.

    I'm working through this example (http://docs.telerik.com/devtools/wpf/controls/raddataservicedatasource/getting-started/creating-the-data-bound-controls), but instead of WCF services, I'm using OData version 7.

    Everything works fine, except when I'm trying to apply even a single filter on columns containing enum elements, I'm getting this exception :

    Babken Gevorgyan, [01.08.17 13:36]
    System.Windows.Data Error: 8 : Cannot save value from target back to source. BindingExpression:Path=IsActive; DataItem='DistinctValueViewModel' (HashCode=2921675); target element is 'CheckBox' (Name=''); target property is 'IsChecked' (type 'Nullable`1') NotSupportedException:'System.NotSupportedException: Could not convert constant Credit expression to string.
       at Microsoft.OData.Client.ExpressionWriter.VisitConstant(ConstantExpression c)
       at Microsoft.OData.Client.ALinqExpressionVisitor.Visit(Expression exp)
       at Microsoft.OData.Client.DataServiceALinqExpressionVisitor.Visit(Expression exp)
       at Microsoft.OData.Client.ExpressionWriter.Visit(Expression exp)
       at Microsoft.OData.Client.ExpressionWriter.VisitOperand(Expression e, Nullable`1 parentType, Nullable`1 childDirection)
       at Microsoft.OData.Client.ExpressionWriter.VisitBinary(BinaryExpression b)
       at Microsoft.OData.Client.ALinqExpressionVisitor.Visit(Expression exp)
       at Microsoft.OData.Client.DataServiceALinqExpressionVisitor.Visit(Expression exp)
       at Microsoft.OData.Client.ExpressionWriter.Visit(Expression exp)
       at Microsoft.OData.Client.ExpressionWriter.ExpressionToString(DataServiceContext context, Expression e, Boolean inPath, Version& uriVersion)
       at Microsoft.OData.Client.UriWriter.VisitQueryOptionExpression(FilterQueryOptionExpression fqoe)
       at Microsoft.OData.Client.UriWriter.VisitQueryOptions(ResourceExpression re)
       at Microsoft.OData.Client.UriWriter.VisitQueryableResourceExpression(QueryableResourceExpression rse)
       at Microsoft.OData.Client.DataServiceALinqExpressionVisitor.Visit(Expression exp)
       at Microsoft.OData.Client.UriWriter.Translate(DataServiceContext context, Boolean addTrailingParens, Expression e, Uri& uri, Version& version)
       at Microsoft.OData.Client.DataServiceQueryProvider.Translate(Expression e)
       at Microsoft.OData.Client.DataServiceQuery`1.get_RequestUri()
       at Telerik.Windows.Data.QueryableDataServiceCollectionView`1.ReturnsSingleEntity(DataServiceQuery`1 query)
       at Telerik.Windows.Data.QueryableDataServiceCollectionView`1.BuildDataServiceQuery(Int32 pageIndex)
       at Telerik.Windows.Controls.DataServices.QueryableDataServiceCollectionViewBase.CompletePageMove(Int32 newPageIndex)
       at Telerik.Windows.Data.QueryableCollectionView.MoveToPageCore(Int32 index)
       at Telerik.Windows.Controls.DataServices.QueryableDataServiceCollectionViewBase.MoveToPageCore(Int32 index)
       at Telerik.Windows.Data.QueryableCollectionView.InvalidatePaging()
       at Telerik.Windows.Data.QueryableCollectionView.InvalidatePagingAndRefresh()
       at Telerik.Windows.Data.QueryableCollectionView.OnFilterDescriptorsChanged()
       at Telerik.Windows.Data.QueryableDataServiceCollectionView`1.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.InsertItem(Int32 index, T item)
       at Telerik.Windows.Data.RadObservableCollection`1.InsertItem(Int32 index, T item)
       at Telerik.Windows.Data.FilterDescriptorCollection.InsertItem(Int32 index, IFilterDescriptor item)
       at System.Collections.ObjectModel.Collection`1.Insert(Int32 index, T item)
       at System.Collections.ObjectModel.Collection`1.System.Collections.IList.Insert(Int32 index, Object value)
       at Telerik.Windows.Data.CollectionHelper.Insert(IList target, IEnumerable newItems, Int32 startingIndex, IEqualityComparer itemComparer)
       at Telerik.Windows.Data.ObservableCollectionManager.HandleCollectionChanged(IList sender, NotifyCollectionChangedEventArgs args)

    Babken Gevorgyan, [01.08.17 13:36]
    at Telerik.Windows.Data.ObservableCollectionManager.Telerik.Windows.Data.IWeakEventListener<System.Collections.Specialized.NotifyCollectionChangedEventArgs>.ReceiveWeakEvent(Object sender, NotifyCollectionChangedEventArgs args)
       at Telerik.Windows.Data.WeakEvent.WeakListener`1.Handler(Object sender, TArgs args)
       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.InsertItem(Int32 index, T item)
       at Telerik.Windows.Data.RadObservableCollection`1.InsertItem(Int32 index, T item)
       at Telerik.Windows.Data.FilterDescriptorCollection.InsertItem(Int32 index, IFilterDescriptor item)
       at System.Collections.ObjectModel.Collection`1.Add(T item)
       at Telerik.Windows.Controls.GridViewColumn.OnColumnFilterDescriptorPropertyChanged(Object sender, PropertyChangedEventArgs e)
       at Telerik.Windows.Data.DescriptorBase.OnPropertyChanged(PropertyChangedEventArgs args)
       at Telerik.Windows.Data.DescriptorBase.OnPropertyChanged(String propertyName)
       at Telerik.Windows.Data.DescriptorBase.ResumeNotifications()
       at Telerik.Windows.Controls.GridView.FilteringViewModel.ApplyFilters()
       at Telerik.Windows.Controls.GridView.FilteringViewModel.OnDistinctValuesChanged()
       at Telerik.Windows.Controls.GridView.FilteringViewModel.OnDistinctValuesItemChanged(Object sender, ItemChangedEventArgs`1 e)
       at Telerik.Windows.Data.ObservableItemCollection`1.RaiseGenericItemChanged(ItemChangedEventArgs`1 e)
       at Telerik.Windows.Data.ObservableItemCollection`1.OnItemChanged(ItemChangedEventArgs`1 e)
       at Telerik.Windows.Data.ObservableItemCollection`1.Telerik.Windows.Data.IWeakEventListener<System.ComponentModel.PropertyChangedEventArgs>.ReceiveWeakEvent(Object sender, PropertyChangedEventArgs args)
       at Telerik.Windows.Data.WeakEvent.WeakListener`1.Handler(Object sender, TArgs args)
       at System.ComponentModel.PropertyChangedEventHandler.Invoke(Object sender, PropertyChangedEventArgs e)
       at Telerik.Windows.Controls.ViewModelBase.OnPropertyChanged(String propertyName)
       at Telerik.Windows.Controls.GridView.DistinctValueViewModel.set_IsActive(Boolean value)'

     

    Thanks.

  2. Babken
    Babken avatar
    2 posts
    Member since:
    Feb 2017

    Posted 02 Aug in reply to Babken Link to this post

    This is the link to a simple example to help in reproducing my problem:

    https://drive.google.com/file/d/0B9R0wOOhMo2VTXNzWjZIb3RtWEk/view?usp=sharing

  3. Yoan
    Admin
    Yoan avatar
    1128 posts

    Posted 07 Aug Link to this post

    Hi,

    It seems that the Linq expression which is used in our DataServiceDataSouce can not be mapped to URI. This happens at the following line:

    internal override WCF.DataServiceQuery BuildDataServiceQuery(int pageIndex)
            {
                IQueryable newQuery = this.DataServiceQuery;
                newQuery = newQuery.Where(this.FilterDescriptors);

    I am not sure why, because this is not in our scope. I've found only this information on the matter:

    "The set of queries expressible in the LINQ syntax is broader than those enabled in the URI syntax that is used by OData data services. A NotSupportedException is raised when the query cannot be mapped to a URI in the target data service. For more information, see the Unsupported LINQ Methods in this topic."

    You can check this MSDN article for a reference. However, I will try to debug the Microsoft.OData.Client.DataServiceQuery in order to see what exactly is happening. I will reply again in this forum thread, once I have more information.

    Regards,
    Yoan
    Progress Telerik
    Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
  4. Aram
    Aram avatar
    2 posts
    Member since:
    Aug 2017

    Posted 07 Aug Link to this post

    Hi Yoan,

    We have investigated the issue and found out that probably the issue is in the Telerik.Windows.Data assembly.

    The problem is in the handling enum conversion when building an expression tree.

    We have done a dirty fix in the Telerik.Windows.Data assembly. ( To be able to continue our review of your product. )

    Particularly TryConvertExpressionTypes and CreateValueExpression functions in OperatorValueFilterDescriptorExpressionBuilderBase class.

    You can see "fix" details here, hope you can investigate and get this fix to "normal state".

    https://gist.github.com/arkoc/ef24d8560c8ceeab069a0219db5cfae7

    Thanks,
    Aram.

  5. Aram
    Aram avatar
    2 posts
    Member since:
    Aug 2017

    Posted 07 Aug in reply to Aram Link to this post

    And yes a small fix in the TypesAreDifferent function to allow calling of the TryConvertExpressionTypes function
  6. Yoan
    Admin
    Yoan avatar
    1128 posts

    Posted 10 Aug Link to this post

    Hi Aram,

    Thank you for the cooperation.

    I have logged a new bug report in our feedback portal regarding this issue so that it can be prioritized and addressed. You can follow the item in order to get notified once we start working on a fix for this:  Exception is thrown when filtering an enum column.

    I've also updated your Telerik points.

    Regards,
    Yoan
    Progress Telerik
    Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
Back to Top