I have a class called Item
:
public sealed class Item
{
public int Id { get; set; }
public string Name { get; set; }
public List<Language> Languages { get; set; }
}
and
public sealed class Language
{
public int Id { get; set; }
public string Code { get; set; }
}
I want to get a list of Item
based on a match language.
So:
string currentLangCode = "EN";
List<Item> items = GetListOfItems();
// that's not correct, I need an advice here
var query = from i in items
where ( i.Languages.Select(l=>l).Where(l=>l.Code.Equals(currentLangCode) )
select i;
I want to filter a list of items if their sublist (means list of languages) contains currentLanguage
.
How to do that using LINQ?