No applicable method 'Contains' exists in type Int32?

Hi
I am currently trying to filter my query in the parameters query dialog
I receive
No applicable method 'Contains' exists in type 'Int32?'
message.
Actually I want to filter SchoolIDs with a SelectedSchoolIDs.

Would you help me solve this message?

Thank you

new Query() { Filter = $@"i => i.SchoolID.Contains(@0)", FilterParameters = new object[] { selectedSchools.Select(n=>n.SchoolID).ToList() } }

The exception is self explanatory, you should use ==.

Thanks for the reply, I will update accordingly.

Let me update my case,

I would like to filter School IDs with the Selected SchoolIDs.

I can do this with

${result.Where(i=> selectedSchools.Select(n=>n.SchoolID).ToList().Contains((int)i.SchoolID))

But this way, results will still have SchoolID column, which I don't want to have them because I need Distinct values without the SchoolIDs in the results.

So I want to filter my data before getting the results and then select the required columns.

The way I know is to apply a query like this:

new Query() { Filter = $@"i => i.SchoolID.Contains(@0)", FilterParameters = new object[] { selectedSchools.Select(n=>n.SchoolID).ToList() } }

But this didnt work, can not filter by using "Contains", to overcome this problem.

What would you suggest, any help would greatly appreciated.

Thank you.

Ps: selectedSchoolIDs, more than one.

School ID is a number, not a collection or string and therefor does not have a .Contains method.

In strings .Contains refers to a character or group of characters existing in the overall string ("Hello" contains "lo")

In a collection .Contains refers to a specific object instance being in the collection already (selectedSchools.Contains(selectedSchool) where selectedSchool is a database record already queried elsewhere.

What exactly are you trying to accomplish?

Filtering by ID (getting a single school by its specific ID): schools.SingleOrDefault(I=>I.Id == schoolId)
Filtering by Collection (getting a group of schools not in a list of already queried schools): schools.Where(I=>!existingSchools.Contains(I))

Both of those examples are returning the database structure (all columns) as results. If you need to process them into a different format then you would use the .Select operator to pull sub-values or generate new classes.

Get a collection of school IDs: schools.Select(I=>I.Id)
Get a collection of SchoolDTO (custom class) based on values: schools.Select(I=>new SchoolDTO(I.Id, I.Name, etc))

TLDR: What's the overall goal you're trying to accomplish here? To me it sounds like your approach is slightly off but I cannot give a fixed example without knowing the source of your data, how you want it to be filtered and what type of result you want to get. I generally assume when referring to something like SchoolId that we're referring to a primary key value which would mean it can never return more than one value anyways...

Ok. That was a great help to me.

After going through the definitions and explanations above,
I was able to manage it and solved the problem.
While getting familiar with the Radzen IDE and the concepts above, it took some time to achieve but helps above worked great.

@Sikaka , @enchev Thanks a lot.

getTblRolesSchoolsResults = ehrisdbGetVwRolesSchoolsResult
.Where(i => selectedSchools.Select(n => n.SchoolID).ToList().Contains((int)i.SchoolID))
.Select(n=> new Ehris.Models.ViewModels.RoleViewModel 
{ RoleID = n.RoleID, Role = n.Role })
.Distinct();