http://blogs.msdn.com/b/brunoterkaly/archive/2010/06/12/creating-an-on-premise-database-and-mvc-web-application-and-migrating-to-windows-azure-and-sql-azure-step-1-of-10.aspx
http://blogs.msdn.com/b/brunoterkaly/archive/2010/06/11/creating-an-on-premise-database-and-mvc-web-application-and-migrating-to-windows-azure-and-sql-azure.aspx
Incorporating the Data Layer
Database objects
Populating the model
Building the LINQ Query
Code Snippet
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; using DataLayer; namespace MvcOnPremise.Controllers { [HandleError] public class HomeController : Controller { ModelStocksContainer _db = new ModelStocksContainer(); public ActionResult Index() { ViewData.Model = (from m in _db.Stocks select m).ToList(); return View(); } public ActionResult About() { return View(); } } }
The View
Looping through our data
The completed View (Index.aspx)
<%@ Page Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage" %> <asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server"> Home Page </asp:Content> <asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server"> <h2>Stocks Data</h2> <hr /> <%foreach (DataLayer.Stocks s in (IEnumerable<DataLayer.Stocks>)ViewData.Model) { %> <b>Ticker Symbol =</b><%=s.TickerSymbol%><br /> <b>Description =</b><%=s.Description%><br /><hr /> <%} %> </asp:Content>
Ready to Start Debugging
The completed On-Premise Version
Upcoming – Converting this application to work with SQL Azure and Windows Azure