Unplanned
Last Updated: 16 Sep 2020 08:04 by Tobias
Vladimir
Created on: 15 Sep 2020 08:08
Category: GridView
Type: Bug Report
7
GridView: NotSupportedException is thrown when mapping an entity object to a custom class
The exception message is: "... is not a valid metadata type for type filtering operations. Type filtering is only valid on entity types and complex types." The exception is observed when using AggregateFunctions and setting up the data with EntityFramework. 
1 comment
Tobias
Posted on: 16 Sep 2020 08:04

Sample code:

 

<telerik:RadGridView 
            Grid.Row="0" 
            ItemsSource="{Binding PagedSource, ElementName=radDataPager}"
            AutoGenerateColumns="False">

            <telerik:RadGridView.Columns>
                <telerik:GridViewDataColumn DataMemberBinding="{Binding A}" Header="CarrierTrackingNumber" />
                <telerik:GridViewDataColumn DataMemberBinding="{Binding B}" Header="LineTotal">
                    <telerik:GridViewDataColumn.AggregateFunctions>
                        <telerik:CountFunction Caption="Count: " />
                        <telerik:SumFunction Caption="Sum: " />
                    </telerik:GridViewDataColumn.AggregateFunctions>
                </telerik:GridViewDataColumn>
            </telerik:RadGridView.Columns>

            <telerik:RadGridView.SortDescriptors>
                <telerik:SortDescriptor Member="A" SortDirection="Descending" />
            </telerik:RadGridView.SortDescriptors>

        </telerik:RadGridView>

 

public class MyClass
        {
            public int Id { get; set; }

            public string A { get; set; }

            public decimal B { get; set; }
        }

 

 

public IQueryable<MyClass> Data { get; set; }

 

public MainWindow()
        {
            InitializeComponent();

            this.DataContext = this;

            var entities = new AdventureWorks2014Entities();

            var queryable = entities.SalesOrderDetail
                .Select(x => new MyClass
                {
                    A = x.CarrierTrackingNumber,
                    B = x.LineTotal,
                    Id = x.SalesOrderDetailID,
                })
                .OrderBy(x => x.Id);

            this.Data = queryable;
        }