

výsledok LINQ dotazu ako ObservableCollection
dá sa nejako zjednodušiť zápis:
attachmentsListBox.ItemsSource = new ObservableCollection<Attachments>();
var attachments =
from attachment in DocumentDB.Attachments
where attachment.DocumentId == Documents.Id
select attachment;
foreach (var attachment in attachments)
((ObservableCollection<Attachments>)attachmentsListBox.ItemsSource).Add(attachment);
aby som tam nemal ten zbytočný cyklus? potreboval by som aby mi linq dotaz vracal namiesto výsledkov typu IEnumerable kolekciu typu ObservableCollection.
Môžeš použiť konštruktor triedy ObservableCollection, ktorý má ako argument kolekciu, podľa ktorej sa naplní.
velice díky
inak tá metóda na konverziu na zoznam .ToList() tam ani nemusí byť konštruktor ObservableCollection akceptuje aj typ IEnumerable.