I have the following class
public class Group
{
public string Id { get; set; }
public string Name { get; set; }
}
and 2 lists List<string> groupRestrict and List<Group> groups
now the group list contains some groups with all fields filled in and I want to select all the restricted groups, the groupRestrict list contains just the name of the groups.
I tried some things, but for some reasons, it always returns an empty list. this as my last test:
var lst = groups.Where(j => groupRestrict.Contains(j.Name)).ToList();
Any clue what might be going wrong?
Edit: Like the comments said, this should have worked, it was the input that had some ' but now I would like to have that the groupRestrict doesn't have to be the exact name, but can use 'like' features.
current expression:
var restrictedGroups = (from gr in groupRestrict join g in groups on gr equals g.Name select g).ToList();
.Joinor.GroupJoin(whether you want a left or full join)Joinfunction in LINQ.groupRestrictis large) - please show a short but complete program demonstrating the problem.