raterus
asked on
LINQ cast to collection classes
I'm looking for a on-liner fix to the following problem.
I have the following collection class
And a method to get some Authors
I run some LINQ
Now my problem, in the above example "filteredAuthors" is now an IEnumerable(Of Author), but I want to quickly get it back to an "Authors" collection. Is there a simple way to do this, other than creating a new "Authors" collection and creating a for loop to add authors back to it?
Thanks!
I have the following collection class
Public Class Authors
Inherits Collection(Of Author)
End Class
And a method to get some Authors
Dim myAuthorsCollection = AuthorModel.GetSomeAuthorDudes()
I run some LINQ
Dim filteredAuthors = myAuthorsCollection.Where(function(p) p.authorTypeID=1)
Now my problem, in the above example "filteredAuthors" is now an IEnumerable(Of Author), but I want to quickly get it back to an "Authors" collection. Is there a simple way to do this, other than creating a new "Authors" collection and creating a for loop to add authors back to it?
Thanks!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.