5
ho il prossimo arhitecture:Selezionare proprietà di un oggetto che si trova in un elenco di oggetti che è anche in un altro elenco di oggetti
public class Element
{
public uint Id { get; set; }
public ICollection<ElementDetails> elementDetails { get; set; }
}
public class ElementDetails
{
public string ElementTitle { get; set; }
public string Content { get; set; }
}
E c'è List<Element> someList
che contiene centinaia di elementi. Sto cercando di ottenere un elenco di ElementTitle (stringhe) che contiene un determinato testo (l'ho chiamato "seed"). Quello che voglio realizzare è un typeahead. Ecco il mio tentativo:
List<Element> suggestedElements = someList.Where(s => s.elementDetails.Any(ss => ss.ElementTitle.Contains(seed))).ToList();
List<string> suggestions = suggestedElements .SelectMany(t => t.elementDetails.Select(x => x.ElementTitle)).ToList() }); // contains all ElementTitle, including those ElementTitle that don't contain the "seed"...
Come posso eliminare quegli elementi che non contengono il seme?
Grazie uomo! Funziona come un fascino! – VladN