3
我正在使用中繼器控件使用RSS源來顯示在我的網站上。我想知道是否有可能在VB中從我的linq查詢中返回一個匿名類型,而不是強類型的RSSItem集合。我知道在C#中這是可能的,但是還沒有能夠找出一個VB的等價物。返回來自VB.NET的LINQ查詢的匿名類型
Public Class RSSItem
Public Property Title As String
Public Property Link As String
Public Property Content As String
Public Property Description As String
Public Property pubDate As String
Public Property category As String
End Class
Dim feedXML As XDocument = XDocument.Load("http://myrssfeed.com/rss.xml")
Dim xns As XNamespace = "http://purl.org/rss/1.0/modules/content/"
Dim feeds = From feed In feedXML.Descendants("item") _
Select New RSSItem With _
{.Title = feed.Element("title"),
.Link = feed.Element("link"),
.Content = feed.Element(xns.GetName("encoded")).Value,
.Description = feed.Element("description"),
.pubDate = feed.Element("pubDate"),
.category = GetCategories(feed.Elements("category"))}