SAMPLE CHAPTER IN ACTION. Revised Edition of Silverlight 4 in Action. Pete Brown MANNING

Similar documents
SQL Server 2005: Report Builder

Team Foundation Server 2012 Installation Guide

Introduction. Introduction

Hands-On Lab. Building a Data-Driven Master/Detail Business Form using Visual Studio Lab version: Last updated: 12/10/2010.

Team Foundation Server 2013 Installation Guide

Secret Server Installation Windows Server 2012

Installing and Configuring Microsoft Dynamics Outlook Plugin to Use with ipipeline MS CRM

Secret Server Installation Windows 8 / 8.1 and Windows Server 2012 / R2

Hypercosm. Studio.

SecureAssess Local. Install Guide. Release 9.0

GETTING STARTED WITH SQL SERVER

Creating XML Report Web Services

Introducing SQL Server Express

Walkthrough: Creating and Using an ASP.NET Web Service in Visual Web Developer

Crystal Reports. For Visual Studio.NET. Reporting Off ADO.NET Datasets

How to Mail Merge PDF Documents

Administration Guide for the System Center Cloud Services Process Pack

Team Foundation Server 2010, Visual Studio Ultimate 2010, Team Build 2010, & Lab Management Beta 2 Installation Guide

Richmond SupportDesk Web Reports Module For Richmond SupportDesk v6.72. User Guide

Microsoft SQL Server Express 2005 Install Guide

Windows Server Update Services 3.0 SP2 Step By Step Guide

maximizing IT productivity

Secret Server Installation Windows Server 2008 R2

aims sql server installation guide

NETWRIX EVENT LOG MANAGER

E-Notebook SQL 12.0 Desktop Database Migration and Upgrade Guide. E-Notebook SQL 12.0 Desktop Database Migration and Upgrade Guide

How to Install and Setup IIS Server

Password Reset Server Installation Guide Windows 8 / 8.1 Windows Server 2012 / R2

Tutorial: Building a Dojo Application using IBM Rational Application Developer Loan Payment Calculator

IMDG Code for Intranet

How to install and use the File Sharing Outlook Plugin

Visual COBOL ASP.NET Shopping Cart Demonstration

QUANTIFY INSTALLATION GUIDE

Using Application Insights to Monitor your Applications

System Administration Training Guide. S100 Installation and Site Management

BUILDER 3.0 Installation Guide with Microsoft SQL Server 2005 Express Edition January 2008

Microsoft Virtual Labs. Administering the IIS 7 File Transfer Protocol (FTP) Server

Install MS SQL Server 2012 Express Edition

Outlook Profile Setup Guide Exchange 2010 Quick Start and Detailed Instructions

To install Multifront you need to have familiarity with Internet Information Services (IIS), Microsoft.NET Framework and SQL Server 2008.

Using Microsoft Visual Studio API Reference

Training module 2 Installing VMware View

NAS 206 Using NAS with Windows Active Directory

O Reilly Media, Inc. 3/2/2007

EventSentry Overview. Part I Introduction 1 Part II Setting up SQL 2008 R2 Express 2. Part III Setting up IIS 9. Part IV Installing EventSentry 11

SELF SERVICE RESET PASSWORD MANAGEMENT DATABASE REPLICATION GUIDE

Advanced Event Viewer Manual

Visual Studio.NET Database Projects

System Center 2012 R2 SP1 Configuration Manager & Microsoft Intune

R i o L i n x s u p p o r r i o l i n x. c o m 1 / 3 0 /

Setting up and Automating a MS Dynamics AX Job in JAMS

User Document. Adobe Acrobat 7.0 for Microsoft Windows Group Policy Objects and Active Directory

ORACLE BUSINESS INTELLIGENCE WORKSHOP

Installing LearningBay Enterprise Part 2

EntroWatch - Software Installation Troubleshooting Guide

Como configurar o IIS Server para ACTi NVR Enterprise

OrgPublisher Silverlight Configuration for Server 2008, IIS 7

OneStop Reporting OSR Portal 4.6 Installation Guide

Installing SQL Express. For CribMaster 9.2 and Later

Getting Started with the Ed-Fi ODS and Ed-Fi ODS API

STATISTICA VERSION 10 STATISTICA ENTERPRISE SERVER INSTALLATION INSTRUCTIONS

Livezilla How to Install on Shared Hosting By: Jon Manning

Deploying BitDefender Client Security and BitDefender Windows Server Solutions

Create a New Database in Access 2010

Microsoft FrontPage 2003

Juris Installation / Upgrade Guide

Download and Installation of MS SQL Server

Ingenious Testcraft Technical Documentation Installation Guide

Creating Reports with Microsoft Dynamics AX SQL Reporting Services

SQL Server Setup for Assistant/Pro applications Compliance Information Systems

The Greenshades Center

E-Notebook SQL 12.0 Desktop Database Installation Guide. E-Notebook SQL 12.0 Desktop Database Installation Guide

Implementing Microsoft SQL Server 2008 Exercise Guide. Database by Design

AES Adaptive Enterprise Solutions

How To Install And Set Up The Database For Quicdoc And Office Therapy (The Applications)

STEP BY STEP IIS, DotNET and SQL-Server Installation for an ARAS Innovator9x Test System

QuadraMed Enterprise Scheduling Combined Service Installation Guide. Version 11.0

Test Lab Guide: Creating a Windows Azure AD and Windows Server AD Environment using Azure AD Sync

Last edited on 7/30/07. Copyright Syncfusion., Inc

Content Author's Reference and Cookbook


TECHNICAL TRAINING LAB INSTRUCTIONS

Hands-On Lab. Web Development in Visual Studio Lab version: Last updated: 12/10/2010. Page 1

Using Microsoft Expression Web to Upload Your Site

How to make a VPN connection to our servers from Windows XP

Connecting to SQL server

Installing Windows Server Update Services (WSUS) on Windows Server 2012 R2 Essentials

How to Create a Delegated Administrator User Role / To create a Delegated Administrator user role Page 1

Installing Cobra 4.7

Chapter 4 Accessing Data

Installation Instructions for Hospital ERP System (AP) Installation Instructions for Hospital ERP System (AP)

FrontDesk. (Server Software Installation) Ver

How to test and debug an ASP.NET application

SQL Server 2008 and SSL Secure Connection

WhatsUp Gold v16.3 Installation and Configuration Guide

Creating a New Database and a Table Owner in SQL Server 2005 for exchange@pam

Automating client deployment

Getting Started with Telerik Data Access. Contents

Sharpdesk V3.5. Push Installation Guide for system administrator Version

Transcription:

SAMPLE CHAPTER IN ACTION Revised Edition of Silverlight 4 in Action Pete Brown MANNING

Silverlight 5 in Action by Pete Brown Appendix A Copyright 2012 Manning Publications

brief contents PART 1 CORE SILVERLIGHT... 1 1 Introducing Silverlight 3 2 XAML and the property system 26 3 The application model and the plug-in 47 4 Working with HTML and browsers 73 5 Out-of-browser applications 95 6 The security model and elevated trust 114 PART 2 CREATING THE USER INTERFACE... 125 7 Rendering, layout, and transforming 127 8 Panels 160 9 Human input 180 10 Text fundamentals 199 11 Editing plain and rich text 225 12 Control basics and UserControls 247 13 Animation and behaviors 272 iii

iv BRIEF CONTENTS 14 Resources, styles, and control templates 307 15 Extensions, converters, custom controls, and panels 337 PART 3 WORKING WITH DATA AND SERVICES... 365 16 Binding 367 17 Data controls: DataGrid and DataForm 410 18 Input validation 433 19 Networking basics 460 20 Working with SOAP services 491 21 RESTful services with the ASP.NET Web API 520 22 Working with XML, JSON, RSS, and Atom 549 23 Duplex, sockets, and local connections 575 PART 4 2D AND 3D GRAPHICS... 601 24 Graphics and effects 603 25 Working with images 630 26 Introduction to 3D 649 27 3D lighting, texturing, and animation 679 PART 5 MAKING THE MOST OF THE PLATFORM... 709 28 Pop-ups, windows, and full-screen applications 711 29 Navigation 734 30 Working with files and directories 761 31 Printing 798 32 COM, Native Extensions, and p-invoke 832 PART 6 BEST PRACTICES... 867 33 Structuring and testing with the MVVM pattern 869 34 Debugging your application 913 35 The install experience and preloaders 929

appendix A: Database, connection, and data model setup In several examples in this book, including those in the printing (see chapter 31), MVVM (see chapter 33), and WCF RIA Services (see ebook appendices D, E, and F), you need to work against database data and an entity data model. For this you ll need SQL Server with the AdventureWorks database loaded. In this appendix, you ll install the database, then create the database connection and the entity data model. The entity data model will be added to the ASP.NET web project in your Silverlight solution. The steps are intended to be performed as part of a larger project setup. You ll be referred to this appendix at a specific point in each of the chapters, by which time you ll already have a basic solution setup. A.1 Install the AdventureWorks database If your database installation doesn t already contain the AdventureWorks database, visit http://msftdbprodsamples.codeplex.com/ to download the latest version for your database version. The CodePlex database sample site includes a number of database releases for the various editions of SQL Server, up to SQL Server 2010 RC0 as of this writing. My own dedicated database server is running SQL Server 2008, and I have a local SQL Server Express 2008 database instance that came with Visual Studio 2010. The sample databases will install on either one. A.1.1 Installing on a dedicated SQL Server instance In this setup and in all of my examples, I m using SQL Server 2008 on a dedicated server. You can install locally or use a separate server or virtual machine (VM). Though I haven t tested with older versions, this should also work on SQL Server 2005. A default installation of Visual Studio 2010 up-level versions (such as Pro and Ultimate) 939

940 APPENDIX A Database, connection, and data model setup includes SQL Server Express 2008. If you have an MSDN subscription, you can also download the developer editions of SQL Server through your subscription program. If you have a full SQL Server 2008 installation, you can download the full MSI and install the suite of databases. Once the database is installed, you can set up the database connection and create the entity data model. The CodePlex site includes a walkthrough (kept current with the releases) showing how to install the sample databases. Depending on the engine you re using and the options selected when you installed your database server, some databases may not be available to you. The only database you use in this book is AdventureWorks, also called AdventureWorks OLTP. You can ignore the warehousing and reporting databases if you wish I don t use them in the examples. There are so many of them, you should simply not bother installing the warehouse databases unless you know you need them for something else. If you re not using a full dedicated installation of SQL Server, you ll want to install using SQL Server Express. A.1.2 Installing on SQL Server Express SQL Server Express comes with most editions of Visual Studio and installs by default. It s the default database server used for ASP.NET membership, role, and session information on a development machine. But because it doesn t install any client tools, many folks don t realize it s there. As with the dedicated SQL Server instance install, you can download the full MSI and install the suite of databases. You can safely ignore the warehousing and reporting databases. Once the database is installed, you can set up the database connection and create the entity data model. If you re not running a full instance of SQL Server, the databases will install locally with SQL Server Express. When using SQL Server Express, you have two options: Install the databases locally, then use them like any other SQL Server installation (this doesn t work in all install scenarios). Install the databases locally, then drag the AdventureWorks.mdb file into your App_Data folder on the ASP.NET project. I prefer the second option; it simplifies the creation of the database connection, and it s supported in most installation scenarios. But either option will typically work. Regardless of whether you used a local SQL Server instance or a remote one, once you have the AdventureWorks database installed you ll need to create the database connection and the entities. A.2 Database connection and entities First create a Silverlight project for the example you re following. Be sure you create the associated web project (the default action), because that s where the connection information and any services will live. The new project dialog for the default Silverlight project type will look like figure A.1. The dialog for the Silverlight Business

Database connection and entities 941 Figure A.1 When creating the Silverlight application, be sure to host the application in a new web application. Application template will be different and will have the options already set; WCF RIA Services projects using the business application template will automatically create the correct projects by default. Once you have the project created, the next step is to add the database connection and create some entities. Right-click the web project in the Solution Explorer and choose Add New Item. In the Data section of the installed templates, select ADO.NET Entity Data Model. Name that entity data model AdventureWorksEntities.edmx. Figure A.2 shows the dialog with the correct template selected and named. Figure A.2 Creating the AdventureWorksEntities entity data model

942 APPENDIX A Database, connection, and data model setup Figure A.3 The first step of the Entity Data Model Wizard. Be sure to choose Generate from Database. Once you click Add, Visual Studio will walk you through a wizard that makes the process of generating the model pretty easy. In the first page of the wizard, choose Generate from Database and click Next. The other option, Empty Model, would require you to build the entities from scratch. Figure A.3 shows the wizard dialog with the correct option selected. You ll then be presented with the Choose Your Data Connection step, as shown in figure A.4. If the AdventureWorks database isn t located in the connection list, click the New Connection button and create a new Microsoft SQL Server (SqlClient) connection to your database. If you already have a connection for AdventureWorks set up, simply select that. The authentication method chosen will differ depending on your SQL Server setup. Figure A.5 shows how my dialog looks, with all the overly interesting parts redacted. Once the connection is created, allow the dialog to save the entity connection string as AdventureWorksEntities. Also, if you re using SQL Server authentication, check the option to include the sensitive data (password) in the connection string, as shown in the two radio buttons in the middle of figure A.4. If saving the connection information makes you uncomfortable, you can either try with Windows Authentication (depends on the machine or network setup) or create a dedicated SQL Server account with limited rights just for the sample. Of the choices, I recommend the dedicated SQL Server account. Once the connection is picked or newly set up, you ll be prompted to select the entities to be added to the model.

Database connection and entities 943 Figure A.4 The Choose Your Data Connection dialog box. If you don t already have an AdventureWorks connection created, click the New Connection button. This screenshot shows the data connection dialog with a valid data connection already selected by default. Figure A.5 Creating a new connection to the AdventureWorks database. Be sure to test the connection.

944 APPENDIX A Database, connection, and data model setup Figure A.6 Select the Contact and Employee tables from the AdventureWorks database. Leave the model namespace set to AdventureWorksModel. A.2.1 Choosing the entities to create On the Choose Your Database Objects page, select the Employee (Human Resources) table and the Contact (Person) table. Leave the other options as is, including setting the namespace to AdventureWorksModel. Figure A.6 shows the correct selected tables and the correct model name. You can name the model anything you d like. But to follow the examples in the book and use the code listings, you ll want to use the names indicated in the screenshots here. At this point, you re able to finish the wizard. The wizard will process for a few seconds, and then add the connection information to your configuration file and the model.edmx and.edmx.cs files to your web project. The created.edmx file should look something like figure A.7 when opened in the designer. Once you have the data model in place, build the solution to get all the types loaded, and then continue with the rest of the sample in the chapter. Figure A.7 The AdventureWorks model viewed in the model designer. Double-click the EDMX file in the web project to view it on the design surface.

SILVERLIGHT/.NET Pete Brown This hands-on guide explores Silverlight from the ground up, covering every feature in rich, practical detail. It is readable and the coverage is comprehensive. You ll master networking, MVVM, and more, with dozens of code samples you can use in Visual Studio or the free Visual Web Developer Express. Silverlight 5 in Action teaches you how to build desktop-quality applications you can deploy on the web. Beginners will appreciate the progression from simple examples to full applications that employ good design and coding practices. Seasoned.NET developers will love how the sample code embraces and extends what they already know. What s Inside Silverlight 5 IN ACTION 2D and 3D graphics and animation Business application services, rules, and validation The MVVM pattern and testing 5 free appendixes (200 pages) available online A background in C# or VB.NET is helpful, but no knowledge of Silverlight or XAML is required. This book is a revised edition of Silverlight 4 in Action. Pete Brown leads Microsoft s Silverlight/XAML Developer Community team. He s been a Silverlight MVP, an INETA speaker, and successful RIA Architect. SEE INSERT As entertaining as it is educational. Pete covers Silverlight 5 like no one else! Joe Suchy, ATC Transportation The go-to source for real Silverlight 5 answers and examples. Dave Campbell, WynApse Hands down THE best reference for everything Silverlight. Michael Crump, Telerik A must-have book for every Silverlight developer. Dave Davis BlueMetal Architects Inc. To download a free ebook plus additional content in PDF, epub and Kindle formats, owners of this book should visit manning.com/silverlight5inaction MANNING $59.99 / Can $62.99 [INCLUDING ebook]