I have a list of result List where it contains List inside of it.I have another list where it contains List alone.I want to filter using a linq query from the data where it should return all the data which contains skill id from the second list.
var list = this._viewModel.Data.Select(T => T.SkillsList);
var filtered = item.Skills.Contains(list.Where(t=>t.ToString()).ToList();
from the first list it contains List of decimals inside the skill list; item.Skills contains list where the fields are skillid and code. item is another object which contains the skillslist.
if skillId is a variable and assuming that SkillsList contains a property called Id. Then the following would work in getting you any data that has the specified skillId.
var list = this._viewModel.Data.Where(t=>t.SkillsList.Any(s=>s.Id == skillId));
If Skillslist is just an array of integers then the following would work.
var list = this._viewModel.Data.Where(t=>t.SkillsList.Any(s=> s == skillId));
Now if you are checking against a list the following would work.
var list = this._viewModel.Data.Where(t=>t.SkillsList.Any(s=> skillsList.contains(s));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With