RadzenDataFilter Fails To Filter On EF ManyToMany property #1087

Closed
opened 2026-01-29 17:48:46 +00:00 by claunia · 3 comments
Owner

Originally created by @andrewbabbittdev on GitHub (Jan 9, 2024).

Describe the bug
RadzenDataFilter Fails To Filter On EF ManyToMany properties.

To Reproduce
I have a repro repository here: https://github.com/AndrewBabbitt97/ManyToMany

If you run it and attempt to set a filter on the Tags field you get the following exception:

fail: Microsoft.AspNetCore.Components.Server.Circuits.CircuitHost[111]
      Unhandled exception in circuit 'sbVgOBHji6R7Bnfe-vWyektx1jnmJBlvaR5lBYtSLII'.
      System.InvalidOperationException: No generic method 'Contains' on type 'System.Linq.Enumerable' is compatible with the supplied type arguments and arguments. No type arguments should be provided if the method is non-generic.
         at System.Linq.Expressions.Expression.FindMethod(Type type, String methodName, Type[] typeArgs, Expression[] args, BindingFlags flags)
         at System.Linq.Expressions.Expression.Call(Type type, String methodName, Type[] typeArguments, Expression[] arguments)
         at System.Linq.Dynamic.Core.Parser.ExpressionParser.ParseEnumerable(Expression instance, Type elementType, String methodName, Int32 errorPos, Type type)
         at System.Linq.Dynamic.Core.Parser.ExpressionParser.ParseMemberAccess(Type type, Expression expression)
         at System.Linq.Dynamic.Core.Parser.ExpressionParser.ParsePrimary()
         at System.Linq.Dynamic.Core.Parser.ExpressionParser.ParseUnary()
         at System.Linq.Dynamic.Core.Parser.ExpressionParser.ParseArithmetic()
         at System.Linq.Dynamic.Core.Parser.ExpressionParser.ParseAdditive()
         at System.Linq.Dynamic.Core.Parser.ExpressionParser.ParseShiftOperator()
         at System.Linq.Dynamic.Core.Parser.ExpressionParser.ParseComparisonOperator()
         at System.Linq.Dynamic.Core.Parser.ExpressionParser.ParseLogicalAndOrOperator()
         at System.Linq.Dynamic.Core.Parser.ExpressionParser.ParseIn()
         at System.Linq.Dynamic.Core.Parser.ExpressionParser.ParseAndOperator()
         at System.Linq.Dynamic.Core.Parser.ExpressionParser.ParseOrOperator()
         at System.Linq.Dynamic.Core.Parser.ExpressionParser.ParseLambdaOperator()
         at System.Linq.Dynamic.Core.Parser.ExpressionParser.ParseNullCoalescingOperator()
         at System.Linq.Dynamic.Core.Parser.ExpressionParser.ParseConditionalOperator()
         at System.Linq.Dynamic.Core.Parser.ExpressionParser.Parse(Type resultType, Boolean createParameterCtor)
         at System.Linq.Dynamic.Core.DynamicExpressionParser.ParseLambda(Type delegateType, ParsingConfig parsingConfig, Boolean createParameterCtor, ParameterExpression[] parameters, Type resultType, String expression, Object[] values)
         at System.Linq.Dynamic.Core.DynamicExpressionParser.ParseLambda(ParsingConfig parsingConfig, Boolean createParameterCtor, ParameterExpression[] parameters, Type resultType, String expression, Object[] values)
         at System.Linq.Dynamic.Core.DynamicExpressionParser.ParseLambda(ParsingConfig parsingConfig, Boolean createParameterCtor, Type itType, Type resultType, String expression, Object[] values)
         at System.Linq.Dynamic.Core.DynamicQueryableExtensions.Where(IQueryable source, ParsingConfig config, String predicate, Object[] args)
         at System.Linq.Dynamic.Core.DynamicQueryableExtensions.Where[TSource](IQueryable`1 source, ParsingConfig config, String predicate, Object[] args)
         at System.Linq.Dynamic.Core.DynamicQueryableExtensions.Where[TSource](IQueryable`1 source, String predicate, Object[] args)
         at Radzen.QueryableExtension.Where[T](IQueryable`1 source, RadzenDataFilter`1 dataFilter)
         at Radzen.Blazor.RadzenDataFilter`1.get_View()
         at Radzen.Blazor.RadzenDataFilter`1.Filter()
         at Radzen.Blazor.RadzenDataFilterProperty`1.SetParametersAsync(ParameterView parameters)

Expected behavior
The grid should be filtered on the selected tags in the filter.

Screenshots
exception

Desktop (please complete the following information):

  • OS: Windows 11 23H2
  • Browser: Chrome 120
  • Version: Radzen 4.23.7 (Also tested against master, same issue)

Additional context
N/A

Originally created by @andrewbabbittdev on GitHub (Jan 9, 2024). <!-- IMPORTANT: Read this first!!! 1. If you own a Radzen Professional or Еnterprise subscription you can report your issue or ask us a question via email at info@radzen.com. Radzen staff will reply within 24 hours (Professional) or 16 hours (Enterprise) 2. The Radzen staff guarantees a response to issues in this repo only to paid subscribers. 3. If you have a HOW TO question start a new forum thread in the Radzen Community forum: https://forum.radzen.com. Radzen staff will close issues that are HOWTO questions. 4. Please adhere to the issue template. Specify all the steps required to reproduce the issue or link a project which reproduces it easily (without requiring extra steps such as restoring a database). --> **Describe the bug** RadzenDataFilter Fails To Filter On EF ManyToMany properties. **To Reproduce** I have a repro repository here: https://github.com/AndrewBabbitt97/ManyToMany If you run it and attempt to set a filter on the `Tags` field you get the following exception: ```bash fail: Microsoft.AspNetCore.Components.Server.Circuits.CircuitHost[111] Unhandled exception in circuit 'sbVgOBHji6R7Bnfe-vWyektx1jnmJBlvaR5lBYtSLII'. System.InvalidOperationException: No generic method 'Contains' on type 'System.Linq.Enumerable' is compatible with the supplied type arguments and arguments. No type arguments should be provided if the method is non-generic. at System.Linq.Expressions.Expression.FindMethod(Type type, String methodName, Type[] typeArgs, Expression[] args, BindingFlags flags) at System.Linq.Expressions.Expression.Call(Type type, String methodName, Type[] typeArguments, Expression[] arguments) at System.Linq.Dynamic.Core.Parser.ExpressionParser.ParseEnumerable(Expression instance, Type elementType, String methodName, Int32 errorPos, Type type) at System.Linq.Dynamic.Core.Parser.ExpressionParser.ParseMemberAccess(Type type, Expression expression) at System.Linq.Dynamic.Core.Parser.ExpressionParser.ParsePrimary() at System.Linq.Dynamic.Core.Parser.ExpressionParser.ParseUnary() at System.Linq.Dynamic.Core.Parser.ExpressionParser.ParseArithmetic() at System.Linq.Dynamic.Core.Parser.ExpressionParser.ParseAdditive() at System.Linq.Dynamic.Core.Parser.ExpressionParser.ParseShiftOperator() at System.Linq.Dynamic.Core.Parser.ExpressionParser.ParseComparisonOperator() at System.Linq.Dynamic.Core.Parser.ExpressionParser.ParseLogicalAndOrOperator() at System.Linq.Dynamic.Core.Parser.ExpressionParser.ParseIn() at System.Linq.Dynamic.Core.Parser.ExpressionParser.ParseAndOperator() at System.Linq.Dynamic.Core.Parser.ExpressionParser.ParseOrOperator() at System.Linq.Dynamic.Core.Parser.ExpressionParser.ParseLambdaOperator() at System.Linq.Dynamic.Core.Parser.ExpressionParser.ParseNullCoalescingOperator() at System.Linq.Dynamic.Core.Parser.ExpressionParser.ParseConditionalOperator() at System.Linq.Dynamic.Core.Parser.ExpressionParser.Parse(Type resultType, Boolean createParameterCtor) at System.Linq.Dynamic.Core.DynamicExpressionParser.ParseLambda(Type delegateType, ParsingConfig parsingConfig, Boolean createParameterCtor, ParameterExpression[] parameters, Type resultType, String expression, Object[] values) at System.Linq.Dynamic.Core.DynamicExpressionParser.ParseLambda(ParsingConfig parsingConfig, Boolean createParameterCtor, ParameterExpression[] parameters, Type resultType, String expression, Object[] values) at System.Linq.Dynamic.Core.DynamicExpressionParser.ParseLambda(ParsingConfig parsingConfig, Boolean createParameterCtor, Type itType, Type resultType, String expression, Object[] values) at System.Linq.Dynamic.Core.DynamicQueryableExtensions.Where(IQueryable source, ParsingConfig config, String predicate, Object[] args) at System.Linq.Dynamic.Core.DynamicQueryableExtensions.Where[TSource](IQueryable`1 source, ParsingConfig config, String predicate, Object[] args) at System.Linq.Dynamic.Core.DynamicQueryableExtensions.Where[TSource](IQueryable`1 source, String predicate, Object[] args) at Radzen.QueryableExtension.Where[T](IQueryable`1 source, RadzenDataFilter`1 dataFilter) at Radzen.Blazor.RadzenDataFilter`1.get_View() at Radzen.Blazor.RadzenDataFilter`1.Filter() at Radzen.Blazor.RadzenDataFilterProperty`1.SetParametersAsync(ParameterView parameters) ``` **Expected behavior** The grid should be filtered on the selected tags in the filter. **Screenshots** ![exception](https://github.com/radzenhq/radzen-blazor/assets/2308261/9d1991f5-5765-44d7-87ea-b561971d959a) **Desktop (please complete the following information):** - OS: Windows 11 23H2 - Browser: Chrome 120 - Version: Radzen 4.23.7 (Also tested against master, same issue) **Additional context** N/A
Author
Owner

@enchev commented on GitHub (Jan 9, 2024):

There is a demo showing exactly this:
0029315c2e

@enchev commented on GitHub (Jan 9, 2024): There is a demo showing exactly this: https://github.com/radzenhq/radzen-blazor/commit/0029315c2e367f0c1de8c8a2081ffd0e02d0eda4
Author
Owner

@andrewbabbittdev commented on GitHub (Jan 9, 2024):

Demo loads all database records in the process memory, this wont work for databases with thousands to millions of records as all the querying happens locally

orders = dbContext.Orders.Include("OrderDetails.Product").Include("Customer").Include("Employee").ToList().AsQueryable();

foreach (var order in orders)
{
    order.ProductIds = order.OrderDetails.Select(od => od.ProductID);
}
@andrewbabbittdev commented on GitHub (Jan 9, 2024): Demo loads all database records in the process memory, this wont work for databases with thousands to millions of records as all the querying happens locally ```csharp orders = dbContext.Orders.Include("OrderDetails.Product").Include("Customer").Include("Employee").ToList().AsQueryable(); foreach (var order in orders) { order.ProductIds = order.OrderDetails.Select(od => od.ProductID); } ```
Author
Owner

@enchev commented on GitHub (Jan 9, 2024):

The demo shows how to use In operator which was implemented especially for your request on the forum however you continuously insisted that nothing is working, the code is never executed and so on even after I've made an example showing how to use the new feature. Since in Northwind there isn't such "many-to-many" property (many-to-many in SQL databases are made with junction tables like OrderDetails in Northwind not by collection properties on the master table) I've made what's possible as a demo.

@enchev commented on GitHub (Jan 9, 2024): The demo shows how to use In operator which was implemented especially for your request on the forum however you continuously insisted that nothing is working, the code is never executed and so on even after I've made an example showing how to use the new feature. Since in Northwind there isn't such "many-to-many" property (many-to-many in SQL databases are made with junction tables like OrderDetails in Northwind not by collection properties on the master table) I've made what's possible as a demo.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/radzen-blazor#1087