How filter datagrid column by int list

I have this custom method
public IActionResult getEmbassyByUser(string user_id)
{
var embassy = baicDb.UserEmbassies.Where(c => c.user_id == user_id).Select(c => c.embassy_id).ToList();
//var embassy = [1,2];
return Json(new { embassy });
}
That returns an int list.
I want to filter datagrid with this lis but I can´t. Is there another solution.

My configuration in radzen is like this:

Y save that value like this: ${usr_embassy} = ${result.embassy}
After invoque my custom method that returns the list.

I'll apreciate your help. Regards.
Patricia Neira

Hi @Patricia_Neira,

The format is:

If you have array variable you can do this:

Hi @enchev, thank you

I already did the configuration you show me. But is not working :frowning:
The data grid stays loading.

Before load the grid I assign a list value to the variable with a custom method:

Then assigned the return value to the variable in Radzen:
${usr_embassy} = ${result.embassy}

And I have the same configuration as you told me

Can you please help me?
Regards

Most probably there is an error, you can check it using your browser console network tab.

This is the console tab:
http://localhost:5000/odata/BaicDB/CarAssignations?$filter=embassy%20in%20(1,2)&$top=10&$skip=0&$count=true&$expand=Car1,Embassy1 500 (Internal Server Error)

And in radzen console I get this:
Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware[1]
An unhandled exception has occurred while executing the request.
System.ArgumentException: Expression of type 'System.Collections.Generic.List1[System.Nullable1[System.Int32]]' cannot be used for parameter of type 'System.Collections.Generic.IEnumerable1[System.Int32]' of method 'Boolean Contains[Int32](System.Collections.Generic.IEnumerable1[System.Int32], Int32)'
Parameter name: arg0
at System.Dynamic.Utils.ExpressionUtils.ValidateOneArgument(MethodBase method, ExpressionType nodeKind, Expression arguments, ParameterInfo pi, String methodParamName, String argumentParamName, Int32 index)
at System.Linq.Expressions.Expression.Call(Expression instance, MethodInfo method, Expression arg0, Expression arg1)

But I don't understand why, I tried as your example, without variable:

Hi @Patricia_Neira,

I’ve just noticed that you are using custom server method instead data-source invoke - my approach with query builder will not work in this case. You can add second parameter to the server method and pass the value as normal parameter. If you hold Radzen license you can send us your project at info@radzen.com to check what's going on.

I went through the same process and I got the 500 (Internal Server Error).

You can check the actual exception in Radzen output pane.

No error at all in Radzen. This only happen when I apply the filter with "in" such as ID in list (1,2). Any other filter works fine.

I just saw that according to the url this app is deployed - you will not see the exceptions of deployed apps in Radzen. The exception is logged in a log file: https://www.radzen.com/documentation/troubleshooting/#aspnet-core

This is what I get in the back end error (Internal 500 error). I created an empty app and use the multi-select option and set the same set up as above.

An unhandled exception occurred while processing the request.

ArgumentException: Expression of type 'System.Collections.Generic.List1[System.Nullable1[System.Int32]]' cannot be used for parameter of type 'System.Collections.Generic.IEnumerable1[System.Int32]' of method 'Boolean Contains[Int32](System.Collections.Generic.IEnumerable1[System.Int32], Int32)'
Parameter name: arg0

System.Dynamic.Utils.ExpressionUtils.ValidateOneArgument(MethodBase method, ExpressionType nodeKind, Expression arguments, ParameterInfo pi, string methodParamName, string argumentParamName, int index)

This sounds a lot like this OData issue - the IN operator does not work in non-nullable int properties which are also foreign key.

Thank You, Korchev, I have figured out my issue after you gave me that link. The reason why I am having issue is because I was filtering it base from a related table. Basically I expand the child related table and use for example ChildTable/ChildTableID in (${myArray})