Personal Website Starter Kit

It is going to be a summary of my PWS learning experience.
First some links that I read during the process.

Due to some reason, all connections are NOT closed in PhotoManager.cs after query execution. I will write a common data access code (a static class) to deal with it.

LINQ to SQL return a typed class/struct

The trick is to project the query result into an ordinary named type with an object initializer:
Paginate is used to demonstrate how the query can be used for further processes.

using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
 
namespace LINQPart3_CSharp
{
    public partial class _Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            int startRow = 10;
            int takeRow = 20;
 
            GridView1.DataSource = BindProducts(startRow, takeRow);
            GridView1.DataBind();
        }
 
        private IQueryable
 BindProducts(int startRow, int takeRow)
        {
            NorthwindDataContext db = new NorthwindDataContext();
 
            var products = from p in db.Products
                           where p.OrderDetails.Count >2
                           select new prod
                           {
                               ID = p.ProductID,
                               Name = p.ProductName,
                               NumOrders = p.OrderDetails.Count,
                               Revenue = String.Format("{0:C}", p.OrderDetails.Sum(o => o.UnitPrice * o.Quantity))
                           };
            //return products.Skip(startRow).Take(takeRow);
            return Paginate(products, startRow, takeRow);
        }
 
        public IQueryable Paginate(IQueryable query, int skip, int take)
        {
            return query.Skip(skip).Take(take);
        }
 
        struct prod {
            public int ID { get; set; }
            public string Name { get; set; }
            public int NumOrders { get; set; }
            public string Revenue { get; set; }
        }
    }
}

A Simple LinqToObjects Snippet

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
 
namespace LinqToObjects
{
    class LinqToObjects
    {
        static void Main(string[] args)
        {
            string[] names = { "James Huddleston", "Pearly", "Ami Know", "Rupli Agarwal", "Beth Christams", "Fabio Claudio", "Vamika Agarwal", "Vidya Varat Agrawaaaa"};
            IEnumerable<string> namesOfPeople =             
                from name in names
                where name.Length >9
                select name;
            foreach (var name in namesOfPeople)
            {
                Console.WriteLine(name);
            }
        }
    }
}