Note: This article is not meant to be a tutorial on LINQ. For other nice introductory articles on LINQ, refer to the following articles on CP and on MSDN:
- LINQ - .NET Language Integrated Query
- LINQ - Blog Posts by Scott Guthrie
- LINQ articles on The Code Project
I started working on this article to get a hands-on experience with various new features of Visual Studio 2008 and of .NET Framework 3.5. I wanted to work on an example that can utilize almost all of the new features and yet be simple enough to understand. This is where the idea of a message board came to me. I thought of ways to use VSTO, WCF, Silverlight, LINQ in all its flavors, and the new ASP.NET controls. However, the project became too big to handle, and so, instead of one big article, I have decided to make it a multi-part article. In each part, I want to utilize some VS 2008/.NET 3.5 feature and extend the message board. Eventually, I want to end up with a threaded discussion forum like that of CP. This article is the first part in the series, and it builds a basic message board.
The article introduces the following new features in VS 2008:
- LINQ to SQL - The article shows how to map existing business objects to a relational database without using the LINQ to SQL designer. It also shows how to create a database using LINQ to SQL and how to execute raw database commands.
- LINQ to Objects - At various places in building the message board, LINQ to Objects has been used to simplify the handling of collections. In later parts, we will see more advanced features of LINQ to Objects.
- WCF Web Programming Model and Syndication - .NET 3.5 introduced the web programming model to WCF. WCF services can be easily accessed using raw HTTP GET and HTTP POST requests as opposed to constructing elaborate messages. WCF also introduces the Syndication API which allows construction and parsing of ATOM and RSS feeds.
- Time Zone Management Classes in .NET 3.5 - Finally, there is a class in .NET 3.5 for handling time zones. The
TimeZoneInfoclass can be used to factor in time zones when handling
DateTimeobjects. The message board website makes use of this class to display the user's date and time information in the time zone of their choice.
DataPager- The ASP.NET
ListViewcontrol is a new member in the family of other data bound controls such as
Repeater. This control offers ultimate flexibility and customization capabilities when using ASP.NET data binding.
- New IDE and Language Features - Throughout the article, I will show the new C# language features and the VS 2008 IDE features which are cool and make life easier.
At different places, I want to indicate clearly the rationale of using or not using a feature. I will try to include information on why to use a feature rather than how to use a feature. Remember, this is only the first part; there are more to come in the later parts. Let's start by looking at what the application does.
The message board application allows users to post messages so that others can view it. This first version has the basic message board functionality, and we will add lots of features to it in the coming parts. The primary purpose of this article is to introduce the new features in VS 2008. As we move along, I intend to develop a "Production Quality" message board. The message board is cross-browser compatible, and has been tested with the following browsers:
- Internet Explorer 7.0
- Mozilla Firefox 2.x
- Opera 9.x
- Safari for Windows
Here are some features of the message board as implemented in this article:
- Users can post and view messages, both anonymously or as registered users.
- The site makes use of ASP.NET membership to manage users, and can plug in with any ASP.NET membership provider such as the SQL membership provider or the Active Directory membership provider.
- Users can view the website in three different themes: Default, Outlook, and Floating. All this is accomplished using CSS and ASP.NET themes.
- Users can view the time a message was posted in a time zone of their choice, which they can configure.
- RSS and ATOM Syndication support.
With ASP.NET, it is pretty simple to create a message board website without writing any code, and just by using designer and declarative programming. You can create a database with appropriate tables, drag and drop data source and data bound controls, and you have a website ready. Such websites serve as excellent prototypes; however, our aim here is to eventually build a "Production Quality" website to which we will add more and more features, and hence the design needs to be flexible. Apart from web based access, we will also need to provide a service based access to the website that will allow desktop and other external applications to interact with the message board. Keeping all these things in mind, I came up with a "layered" architecture for the website. The following diagram shows the different layers and the Visual Studio projects associated with each layer.