Re-sorting a pre-sorted QueryableDataServiceCollectionView inserts duplicate member name in query

0 Answers 3 Views
DataPager GridView
Wizard6650
Top achievements
Rank 1
Iron
Wizard6650 asked on 23 Apr 2024, 03:12 AM | edited on 23 Apr 2024, 03:15 AM

ViewModel.cs:


public QueryableDataServiceCollectionView<MyTable> MyTableView { get; set; }

var dsq = context.MyTable.AddQueryOption("$orderby", "InsertDateTime");
MyTableView = new QueryableDataServiceCollectionView<MyTable>(dsq.Context, dsq)
{
    PageSize = 25,
    AutoLoad = true
};

View.xaml:


<telerik:RadGridView ItemsSource="{Binding ElementName=MyPager, Path=PagedSource}">
    <telerik:RadGridView.Columns>      
        <telerik:GridViewDataColumn Header="Insert Date Time"
                                    DataMemberBinding="{Binding InsertDateTime}" />
    </telerik:RadGridView.Columns>
</telerik:RadGridView>

<telerik:RadDataPager x:Name="MyPager"
                      PageSize="25"
                      Source="{Binding MyTableView}" />

When I click on the Insert Date Time column header, a Microsoft.OData.Client.DataServiceQueryException exception is thrown with the message "Duplicate property named 'insertDateTime' is not supported in '$orderby'."

The query that's spat out by the RadGridView/RadDataPager/QueryableDataServiceCollectionView is /odata/v1/MyTable?$orderby=insertDateTime,InsertDateTime&$top=25

How do I fix this?

For context, MyTable has 10 million records with server-side pagination enabled and the records must be sorted by InsertDateTime when first loaded.

Dimitar
Telerik team
commented on 25 Apr 2024, 10:14 AM

Hi Antik, 

Would it be possible to share the entire Stack Trace of the exception as well? In addition, can you share the implementation of the AddQueryOption method? Such Issues are usually very specific and with a part of the information it is hard to determine what is causing this. 

I am looking forward to your reply.

No answers yet. Maybe you can help?

Tags
DataPager GridView
Asked by
Wizard6650
Top achievements
Rank 1
Iron
Share this question
or