LINQ to Web 2.0 
by Kevin Hoffman 


Example 1: CSS-friendly HTML. 

<li class="xfolkentry"> 
  <div class="link"> 
    <a href="http://www.slashdot.org">Slashdot</a> 
  </div> 
  <div class="description"></div> 
     <div class="meta"> <span class="postdate">8/28/2006</span> 
       ... more text clipped for article ... 
  </div> 
</li> 


Listing One

<table cellspacing="2" cellpadding="3" rules="all" 
  border="1" id="GridView1" 
  style="background-color:#DEBA84;border-color:#DEBA84; 
    border-width:1px; border-style:None;">
  <tr style="color:White;background-color:#A55129;font-weight:bold;"> 
     <th scope="col">title</th> 
     <th scope="col">url</th> 
     <th scope="col">tags</th></tr>
  <tr style="color:#8C4510;background-color:#FFF7E7;"> <td>This is a sample bookmark</td> <td>http://www.sample.com</td>
<td>sample test</td> 
</tr> 
</table>


Listing Two
     
BookmarksDataSetTableAdapters.BookmarksTableAdapter bookTA = 
    new BookmarksDataSetTableAdapters.BookmarksTableAdapter(); 
BookmarkList1.DataSource = 
    bookTA.GetAllBookmarksWrtUser( User.Identity.Name, pageIndex, 
       numRows, ref totalBookmarks); 
TagDataSetTableAdapters.TagsTableAdapter tagTA = 
    new TagDataSetTableAdapters.TagsTableAdapter(); 
TagList1.DataSource = 
    tagTA.GetPopularTags(DateTime.Now.AddDays(-30), User.Identity.Name); 
recentTagsList.DataSource = 
    tagTA.GetRecentTags( DateTime.Now.AddDays(-30), User.Identity.Name); 

Listing Three

Response.ContentType = "text/xml"; 
XElement rssRoot = new XElement("rss", 
   new XAttribute("version", "2.0"), 
   new XElement("channel", 
      new XElement("title", feedTitle), 
      new XElement("link", "http://[my server]/moniqer/default.aspx/"), 
      new XElement("description", feedDescription), 
      new XElement("ttl", "360"), 
      from bookMark in bookmarkList.Take(rowLimit)  
         select new XElement("item", 
            new XElement("title", bookMark.Bookmark.Title), 
            new XElement("link", bookMark.Bookmark.Address), 
            new XElement("pubDate", bookMark.Tags.Last().
                                      CreatedOn.ToString()+ " GMT"), 
            new XElement("Creator", bookMark.Tags.Last().UserID), 
            new XElement("author", bookMark.Tags.Last().UserID), 
            new XElement("description", bookMark.Bookmark.Description), 
            from tag in bookMark.Tags 
               select new XElement("category", tag.Title))); 
Response.Write(rssRoot.ToString()); 
Response.End(); 



2


