Filtering not working because of interface

Hello,
when I filter a grid column it filters it okay but I get the following exception Error: System.NotSupportedException: Deserialization of interface types is not supported. Type 'ISomeInterface'

4 Replies 1 reply marked as answer

VN Vignesh Natarajan Syncfusion Team September 18, 2020 06:38 AM UTC

Hi Ivan,  
 
Thanks for contacting Syncfusion support. 
 
Query: “but I get the following exception Error: System.NotSupportedException: Deserialization of interface types is not supported. Type 'ISomeInterface' 
 
We understand that you are facing exception error while filtering a column in Grid. We need some more details to validate the reported issue further at our end. So kindly share the following details.  
 
  1. Share your Grid code example.
  2. Share details about your datasource along with its type.
  3. Are you facing issue during the initial filter or filter the column for second time.
  4. Share the screenshot of the error along with its stack trace.
  5. If possible share the issue reproducible sample to validate the reported query at our end.
 
Above requested details will be helpful for us to validate the reported query at our end and provide solution as early as possible  
 
Regards, 
Vignesh Natarajan  
  



KI Krasimir Ivanov September 18, 2020 08:29 AM UTC

This happens when the data source is a IEnumerable of some interface. After the grid is rendered I try to filter a column for the first time, select equal to and write a string to filter by. Then I get the exception. 


KI Krasimir Ivanov September 18, 2020 08:37 AM UTC

Here is the stack trace:




VN Vignesh Natarajan Syncfusion Team September 21, 2020 12:16 PM UTC

 
Thanks for sharing the details.  
 
From your query we understand that you are facing issue while binding the datasource in form of IEnumerable of some interface. We do not have support for direct interface binding support, as model type is required for various operations like column field mapping, validation and model instance creation during editing/adding. So we suggest you to bind the data by using a specific model type which inherits the interface. 
 
For your convenience we have prepared a sample using interface and specific model to bind data to Grid and perform Data Operation. Refer the below code example.  
 
@inject IOrderService OrderService 
 
<SfGrid DataSource="@Orders" AllowFiltering="true" AllowPaging="true" Height="315"> 
    <GridFilterSettings Type="Syncfusion.Blazor.Grids.FilterType.Menu"></GridFilterSettings> 
. . . . . . 
</SfGrid> 
 
@code{ 
    public IEnumerable<Order> Orders { getset; } 
    protected override async Task OnInitializedAsync() 
    { 
        Orders = await OrderService.GetEmployees(); 
    }  
} 
 
public class OrderService : IOrderService    {                public async Task<IEnumerable<Order>> GetEmployees()        {            IEnumerable<Order> employees;            employees = Enumerable.Range(1, 75).Select(x => new Order()            {                OrderID = 1000 + x,                CustomerID = (new string[] { "ALFKI""ANANTR""ANTON""BLONP""BOLID" })[new Random().Next(5)],                Freight = 2.1 * x,                OrderDate = (new DateTime[] { new DateTime(2010, 5, 1), new DateTime(2010, 5, 2), new DateTime(2010, 5, 3), })[new Random().Next(3)],            }).ToList();            return employees;        }    }public interface IOrderService   {       Task<IEnumerable<Order>> GetEmployees();   }
 
 
Kindly download the sample from below  
 
 
Please get back to us if you have further queries.   
 
Regards, 
Vignesh Natarajan  
 


Marked as answer
Loader.
Up arrow icon