I have a class/entity over a project.
Entity example:
public class Project
{
public int Id { get; set; }
public string? ProjectId { get; set; }
public string Name { get; set; }
}
In Blazor file I have this code below. projList get data from my repository, filterList = projList works
@code {
private IEnumerable<Project> projList { get; set; } = new List<Project>();
private List<Project> filterList { get; set; } = new List<Project>();
public string projFilter { get; set; } = string.Empty;
..
private async Task ApplyProjFilter()
{
..
filterList = projList.Where(p => p.ProjectId.Contains(projFilter)).ToList();
..
}
I get an error on the above instruction with .Contains. I can use
(p => p.ProjectId == projFilter).ToList()
but I want to filter my list on the run when the user writes a filter in the textbox and show the projects that contain that input string.
.Contains works if I use it in my repository when I read data from the server but I will not use it on the run because it will cause a lot of questions to SQL-server.
Any idéa what is wrong?
I'm using the latest netcore and efcore and Visual Studio 2019.