can somebody help me? How can I get List<Episode>
from List<Show>
where Episodes.Seen == false
?
public class Show
{
public string Name { get; set; }
public List<Episode> Episodes { get; set; }
}
public class Episode
{
public string Name { get; set; }
public Nullable<bool> Seen { get; set; }
}
Thank you very much for tour help.
使用简单的Linq
语句。
var episodes = shows.SelectMany(s=>s.Episodes.Where(e=>e.Seen.HasValue && !e.Seen.Value));
You can do this using LINQ, like so:
using System.Linq;
IEnumerable<Episode> unseenEpisodes = (from show in shows
from episode in show.Episodes
where (episode.Seen.HasValue && episode.Seen.Value == false)
select episode);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.