I need help to select all Titles from List"FeedItem" that is inside of List"Feed" where Feed.Name matches a string from a combobox.
Below is my attempt, which is not succesful, might be on the wrong road.
var loadFeedData = fillFeed.GetAllFeeds();
var filteredOrders =
loadFeedData.SelectMany(x => x.Items)
.Select(y => y.Title)
.Where(z => z.Contains(flow)).ToList();
To understand things better I'll post the Feed.cs code as well.
public class Feed : IEntity
{
public string Url { get; set; }
public Guid Id { get; set; }
public string Category { get; set; }
public string Namn { get; set; }
public string UppdateInterval { get; set; }
public List<FeedItem> Items { get; set; }
}
This is the Whole Code that I'm trying to get working, filling a ListView with the Title, based on the Name of the Listview with Feed.Name that I select.
private void listFlow_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
{
listInfo.Items.Clear();
listEpisode.Items.Clear();
if (listFlow.SelectedItem != null)
{
string flow = listFlow.SelectedItem.ToString();
var loadFeedData = fillFeed.GetAllFeeds();
var filteredOrders = loadFeedData
.Where(f => f.Name == myStringFromComboBox)
.SelectMany(f => f.Items)
.Select(fi => fi.Title);
listEpisode.Items.Add(filteredOrders);
}
}
- Posted whole code to clear out some ??
loadFeedData
.Where(f => f.Name == myStringFromComboBox)
.SelectMany(f => f.Items)
.Select(fi => fi.Title);
I believe you are looking for:
List<string> titles = loadFeedData.Where(f => f.Name == "SomeName")
.SelectMany(f => f.Items.Select(subItem => subItem.Title))
.ToList();
loadFeedData
based on NameTitle
from List<FeedItem>
SelectMany
to return an IEnumerable<string>
ToList
to get a List<string>
back.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