Hey guys,
since we updated to Syncfusion version 19.4.42 we cannot peform filtering in our grids due to a change you did in the Syncfusion.Blazor.DataOperations.cs file.
You changed
public static IQueryable<T> PerformFiltering<T>(
IQueryable<T> dataSource,
List<WhereFilter> whereFilter,
string condition)
{
return QueryableOperation.PerformFiltering<T>(dataSource, whereFilter, condition);
}
to
public static IQueryable<T> PerformFiltering<T>(
IQueryable<T> dataSource,
List<WhereFilter> whereFilter,
string condition)
{
return QueryableOperation.PerformFiltering<T>(Queryable.OfType<T>(dataSource), whereFilter, condition);
}
The Queryable.OfType<T> throws an exception to most of our DTOs. The exception looks like this:
System.NotSupportedException: 'UserReportingDto' is not a valid metadata type for type filtering operations. Type filtering is only valid on entity types and complex types.
Since this was possible before I want to ask you what do we have to change or look for? Or is it a known issue on your side? Is this intended for some query improvements or what's the reason for this?
Best regards
Hi,
as additional information: We use AutoMapper to map the Database model into the DTO.
dataSource = Mapper.ProjectTo<TTarget>(SourceData, QueryParamsForAutomapper);
Best regards
Hello Monisha! Thanks for your reply.
We tried to reproduce the case in a separate project but weren't able to because we need a database connection and our project is too big to share - but we have more informations that might help!
One important information was missing:
We are using the EntityFramework. I'll share you an example of a data base entity (UserReporting.cs) and a dto (UserReportingDto.cs). The SfGrid is of type UserReportingDto. We don't cache the entries and filter directly on the database and this is where the issue appears. You can see this in the full stack trace - also to find in the attachment (stacktrace.txt) -> the operation tries to translate the sql expression on the db and this is not possible.
We are also using a custom data adaptor in the grid - also shared in the attachment (HQDataComponentAdaptor.cs). The current implementation of DataOperations.PerformFiltering is used currently at at line 234 of HQDataComponentAdaptor:
public static IQueryable<T> PerformFiltering<T>(
IQueryable<T> dataSource,
List<WhereFilter> whereFilter,
string condition)
{
return QueryableOperation.PerformFiltering<T>(Queryable.OfType<T>(dataSource), whereFilter, condition);
}
We found a workaround for now - if we use this implementation:
public static IEnumerable<T> PerformFiltering<T>(
IEnumerable<T> dataSource,
List<WhereFilter> whereFilter,
string condition)
{
return (IEnumerable<T>) QueryableOperation.PerformFiltering<T>(dataSource.AsQueryable<T>(), whereFilter, condition);
}
To use this, we have to cast our data source to an IEnumerable and Cast the result of this call back to an IQueryable. It works but doesn't feel good and might impact the performance.
This behaviour just appears if the filter operation is directly running in the database. We also have grids with cached data and there everything is fine.
Hope this helps to find our issue, the basic you need to reproduce is a database connection and the grid filtering on the database.
Best regards and thanks for the investigation already!
Patrick
Thank you very much!
I'm looking forward for the update.
Thanks for your work guys, best regards