I am having two lists and filter based on a group of values.
var UserIdList = response.Users.Select(p => p.Id).ToList();
var filteredRecords =
(from o in om.Organizations join u in om.Users on o.Id equals u.OrganizationId where UserIdList.Contains(u.Id)
select new { Enabled = o.Enabled, Id = u.Id }).ToList();
Now i want to set 'Exists' property in 'response.Users' to true if 'Id' exists in filteredRecords.
Please let me know how can I set value with out using foreach loop.
I have tried with
response.Users.Where(x => x.Exists = (filteredRecords .Any(z => z.Id == x.Id))).ToList();
but could not succeed as it is giving only filter results. I want full records which are matched and which are not
Linq doesn't really support update scenarios as it's for querying data.
For lists however there's a ForEach extension method:
Is this clearer to read and easier to understand than a foreach loop...
Edit (after question updates)
What you want to do is to work with a subset of users and update the values.
you could of course use: