C# - Convert Implict Type to ObservableCollection

Posted by user70192 on Stack Overflow See other posts from Stack Overflow or by user70192
Published on 2010-02-28T15:48:05Z Indexed on 2010/03/20 17:51 UTC
Read the original article Hit count: 291

Filed under:
|
|

Hello,

I have a LINQ statement that returns an implicit type. I need to get this type to be an ObservableCollection in my Silverlight 3 application. The ObservableCollection constructor in Silverlight 3 only provides an empty constructor. Because of this, I cannot directly convert my results to an ObservableCollection. Here is my code:

ObservableCollection<MyTasks> visibleTasks = e.Result;
var filteredResults = from visibleTask in visibleTasks
                      select visibleTask;

filteredResults = filteredResults.Where(p => p.DueDate == DateTime.Today);
visibleTasks = filteredResults.ToList();  // This throws a compile time error

How can I go from an implicitly typed variable to an observable collection?

Thank you

© Stack Overflow or respective owner

Related posts about Silverlight

Related posts about c#