Home > Store

Microsoft Visual Studio LightSwitch Unleashed

Register your product to gain access to bonus material or receive a coupon.

Microsoft Visual Studio LightSwitch Unleashed


  • Sorry, this book is no longer in print.
Not for Sale


  • Copyright 2012
  • Edition: 1st
  • Book
  • ISBN-10: 0-672-33553-0
  • ISBN-13: 978-0-672-33553-2

Microsoft® Visual Studio® LightSwitch® Unleashed

Alessandro Del Sole

Microsoft Visual Studio LightSwitch represents a breakthrough in business application development for Windows clients, the Web, and the cloud. Using this new tool, you can build powerful data-centric applications with far less code than ever before. Microsoft Visual Studio LightSwitch Unleashed is the first comprehensive, start-to-finish guide to this powerful new tool. Written by longtime Visual Basic expert and Microsoft MVP Alessandro Del Sole, this book covers everything Microsoft developers need to know to make the most of LightSwitch–from the absolute basics to the most advanced enterprise techniques.

You learn how to use LightSwitch to build modern, scalable, customized line-of-business applications that automatically leverage technologies such as Silverlight, WCF, and SQL Server Express with no effort or expertise on your part. Through hands-on examples, Del Sole guides you through building solutions that can integrate and analyze business information from virtually any source, crafting custom logic that solves your company’s unique problems, and delivering state-of-the-art usability through professional-quality user interfaces.

  • Implement features such as screen navigation, data interaction, paging, and Excel export, with absolutely no coding
  • Build simple data-centric applications and add power to them with relationships and details
  • Rapidly create customized queries, filters, sorts, and reports
  • Aggregate data from many locations, including SharePoint, SQL Server, and the cloud
  • Simplify the implementation of application-level data validation
  • Protect your applications with authentication and authorization
  • Fine tune your code for scalability and performance
  • Streamline deployment to local computers, web servers, and the Windows Azure cloud
  • Use .NET code to define custom behaviors related to data and the user interface
  • Understand how LightSwitch applications are architected and how they are handled by Visual Studio
  • Use LightSwitch with other Visual Studio tools to manage the entire application life cycle
  • Efficiently debug LightSwitch code–and create code that’s easier to debug

Category: Microsoft Programming

Covers: LightSwitch

User Level: Intermediate—Advanced


Download all examples and source code presented in this book as they are available from informit.com/title/9780672335532


Source Code

CSharppartI.zip (235 MB)
CSharppartII.zip (192 MB)
VBpartI.zip (354 MB)
VBpartII.zip (291 MB)

Sample Content

Online Sample Chapter

Building Data-Centric Applications with Microsoft Visual Studio LightSwitch

Sample Pages

Download the sample pages (includes Chapter 3 and Index)

Table of Contents

Part I Building Applications with LightSwitch

Chapter 1 Introducing Visual Studio LightSwitch 1

Who Uses LightSwitch?

A Short History of Microsoft Business Tools

    Microsoft Access with Visual Basic for Applications

    Microsoft Visual Basic 6

    Microsoft Visual FoxPro

    Microsoft Visual StudioNET (2002 to 2010)

About Visual Studio LightSwitch.

    Technologies Used Behind the Scenes

    Available Editions.

    Companion Source Code

Setting Up the Development Machine

    Operating System

    Development Environment.

    Server Components

    Database Tools

    Controls and Toolkits.

What You Need to Know About Programming


Chapter 2 Exploring the IDE

Getting Started with Visual Studio LightSwitch

    Introducing the Start Page

    Creating New Projects and Exploring Solutions

    The LightSwitch Designer

    The Entity Designer

    The Screen Designer

    The Properties Window

    The Query Designer

    The Application Designer

    The Code Editor.

    Building, Running, and Debugging Applications.

    Managing and Arranging Windows

Getting Help

Visual Studio 2010 with LightSwitch


Chapter 3 Building Data-Centric Applications

Creating a New Application

Creating a New Data Source.

    Adding Entity Properties.

    Building a Complete Entity.

    Data Storage

The User Interface: Implementing Screens

    Controls Overview.

    Creating a Data Entry Screen.

    Creating a Search Screen.

Testing the Application on the Development Machine

    Starting the Application as a Desktop Client

    Adding and Editing Data

    Displaying and Searching Data

    Exporting Data to Microsoft Excel

    Basic Screen Customizations.

    Running the Application as a 3-Tier Desktop Client

    Running the Application in the Web Browser.

Input-Data Validation

    Required Fields Validation

    String-Length Validation.

    Date Validation.

    Number Validation

Default Validation of Business Types

    Validating Email Addresses.

    Validating Phone Numbers

    Validating Images.

    Validating Money.


Chapter 4 Building More-Complex Applications with Relationships and Details Screens

Creating a New LightSwitch Project

Designing Complex Data Sources.

    Entities That Define Choice Lists.

    Working with the Money Data Type

    Adding Relationships

    Using Computed Properties

More-Complex, Business-Oriented User Interfaces.

    Creating Data Entry Screens

    Creating Search Screens

    Running the Application and Entering Data.

    Editing Data with Editable Grids

    Handling Master-Details Relationships with Details Screens

    Editing the Screen Navigation Control

    Customizing the Look and Feel of Screens

Implementing Data Validation.

    Validation on Master-Details Relationships


Part II Manipulating Data

Chapter 5 Customizing Data Validation

Understanding the Validation Model

    Built-In Validation Rules

Writing Custom Validation Rules

    Client Validation: Validating Entity Properties

    Client and Server Validation: Validating a Single Entity.

    Data Validation on the Server: Validating Entity Collections

    Validation in Master-Details Relationships

    For the Experts: Implementing Complex Validation Rules with theNET Framework


Chapter 6 Querying, Filtering, and Sorting Data

Querying Data in LightSwitch

Applying Filters.

    Applying Filters at the Data Level

    Understanding the Query Event Model

    Applying Filters at the Screen Level

Applying Sorting Logic

    Sorting at the Data Level.

    Sorting at the Screen Level

Basing Queries on Other Queries.


Chapter 7 Customizing Applications with Buttons, COM Automation, and Extensions

Customizing the Command Bars.

    Adding Built-In Buttons to the Screen Command Bar

    Adding and Managing Custom Buttons

    Handling More-Complex Scenarios with COM Interoperability

Downloading, Installing, and Using Extensions

    Extensions Types in Visual Studio LightSwitch.

    Downloading and Installing Extensions.

    Using Extensions


Chapter 8 Aggregating Data from Different Data Sources

Connecting to SQL Server Databases.

    Installing the Sample Northwind Database.

    Creating New Applications on Existing SQL Server Databases.

    Aggregating Data from Existing Databases into LightSwitch Applications

Database in the Cloud: Connecting to SQL Azure

    Establishing Connections to SQL Azure

    Creating a SQL Azure Database

    Connecting LightSwitch Applications to SQL Azure.

Collaboration: Working with Lists from SharePoint 2010

    Running the Default Website

    Configuring a Vacation Plan Calendar on SharePoint 2010

    Extending LightSwitch Applications with SharePoint Data.


Part III Securing and Deploying Applications

Chapter 9 Implementing Authentication and Authorization

Understanding Authentication

Implementing Windows Authentication.

    Setting Up the Development Environment.

    Authorization: Settings Permissions

    Writing the Permission Logic

    Permission Logic on Entities.

    Permission Logic on the User Interface.

    Debugging the Application.

    Creating User Roles and Administering the Application

Implementing Forms Authentication

    Publishing Applications with Forms Authentication

    Testing the Application with Different Credentials

Permission Elevation on Server Code


Chapter 10 Deploying LightSwitch Applications

Deployment Fundamentals

    Understanding 2-Tier and 3-Tier Applications.

Preparing the Application for Deployment.

    Specifying the Application Name and Logo.

    Styling the Application

    Runtime Settings

    Localizing an Application.

Deploying 2-Tier Applications

    Client Configuration

    Application Server Configuration

    Publish Output.

    Database Connections


    Other Connections

    Specifying a Certificate

    Publish Summary

    Publishing and Deploying the Application.

Deploying 3-Tier Applications

    Configuring the Target Web Server

    Publishing the Application

    Remotely Publishing to a Web Server

    Creating and Importing Packages into IIS

Deploying to Windows Azure

    Preparing Applications to Deployment


Part IV Advanced LightSwitch

Chapter 11 Handling Events in Code

Working with Entities in Code.

    Understanding Data Objects

    Handling Data Events in Code

Handling Custom Query Events in Code

Handling Screen Events in Code

    Button Methods

    General Methods

    Collection Methods

Launching Screens Programmatically

    Opening Screens Without Passing Parameters

    Opening Screens by Passing Parameters


Chapter 12 Dissecting a LightSwitch Application

Applications Architecture and Tiers

    Architecture Overview

    Understanding the Data Access and Storage Tiers

    Understanding the Logic Tier.

    Understanding the Presentation Tier

Dissecting LightSwitch Projects.

    Overview of LightSwitch Solutions

    Server-Side Projects

    Middle-Tier Projects

    Client-Side Projects


Chapter 13 Advanced LightSwitch with Visual Studio 2010

Managing the Application Life Cycle with TFS 2010.

    Connecting to Team Foundation Server.

    Creating New Team Projects

    Submitting Projects to Source Control.

    Creating and Assigning Work Items

    Retrieving Specific Project Versions with Version Control

    Automating Builds

Code Metrics

Unit Testing Your Helper Code

    Creating a Test Project

    Creating Unit Tests

Analyzing the Execution Flow with IntelliTrace

    IntelliTrace Options

    IntelliTrace in Action with LightSwitch

    IntelliTrace Log Files


Chapter 14 Debugging LightSwitch Applications

Debugging Applications.

    The Error List Tool Window.

    Breakpoints and Data Tips.

    Debugging in Steps

    About Runtime Errors.

    The Edit and Continue Feature

Advanced Debugging Instrumentation

    Breakpoints and Trace Points Unleashed.

    Showing a Variables Value in the Locals Window.

    Evaluating Expressions in the Command Window

    Understanding the Method Calls Flow in the Call Stack Window

    Watch Windows

    Analyzing Threads with the Threads Window.

Understanding Debugger Visualizers

Debugging in Code.

    The Debug Class.

    Using Debugger Attributes in Code.


Part V Extensibility

Chapter 15 Customizing the IDE

Customizing Visual Studio LightSwitch

Customizing Commands and Toolbars

    Customizing an Existing Toolbar

    Creating a New Custom Toolbar.

Managing User Settings

    Exporting Settings

    Importing Settings

Using, Creating, and Managing Reusable Code Snippets

    Using Code Snippets

    The Code Snippet Manager

    Creating and Using Custom Code Snippets


Chapter 16 Customizing Applications with Custom Controls

Building Custom Controls

Creating Controls with Visual Studio 2010

    Implementing and Aggregating Chart Controls.

    Binding the User Control to Data and the Screen

Integrating Bing Maps

    Claiming Your Bing Maps Developer Keys.

    Making Bing Maps Available to LightSwitch

    Updating Entities to Support Bing Maps

    Adding Bing Maps to Screens.


Chapter 17 Implementing Printing and Reporting

Using the Office Integration Extension

    Overview of the Class Library

    Creating Emails and Appointments with

    Microsoft Outlook

    Exporting to Microsoft Word and to PDF

    Importing and Exporting Data with

    Microsoft Excel 2010

Using SQL Server Reporting Services

Reporting Extensions from Microsoft Partners

    XtraReports from Developer Express

    NetAdvantage for LightSwitch from Infragistics

    OLAP Extension from Component One.

    Telerik Reporting for Silverlight.

Using Custom Controls for Printing and Reporting

    Creating a Visual Report as a User Control

    Displaying the Report in the User Interface

    Silverlight’s Printing APIs


Chapter 18 LightSwitch Extensibility: Themes, Shells, Controls, and Screens

Understanding the Extensibility Model

Creating Themes

    Creating a New Extensibility Project

    Setting Extension Properties

    Adding a Theme to the Extensibility Project.

    Editing Themes with Visual Studio 2010.

    Editing Themes with Expression Blend 4

    Making the Green Theme

    Testing the Custom Theme.

Creating Custom Shells

    Creating Extensibility Projects for Custom Shells

    Editing the Official Sample from Microsoft

Sharing Custom Controls.

    Available Control Types

    Creating Control Extensions.

Creating Screen Templates

    Designing Custom Screen Templates

    Implementing the IScreenTemplate Properties

    Generating the Screen Content Tree.

    Adding Code to the Screen.

    Testing the Screen Template

    Screen Templates Tips and Tricks


Chapter 19 LightSwitch Extensibility: Data and Extension Deployment

Creating Business Types.

    Implementing a New Business Type

    Implementing the Data Type Definition

    Implementing Data Validation.

    Designing Controls

    Testing the Extension

Creating and Using Custom Data Sources with WCF RIA Services

    TheNET Framework for WCF RIA Services

    Creating WCF RIA Services to Work with XML Data

    Calling WCF RIA Services from LightSwitch Applications

    Calling Stored Procedures Through WCF RIA Services

Sharing Custom Data Sources

    Testing Custom Data Sources

    Handling Connection Strings

Deploying Extensions to Others.

    Preparing the Deployment Manifest.

    Uploading VSIX Packages to the Visual Studio Gallery

    Releasing Extension Updates



Appendix A Installing and Configuring Visual Studio LightSwitch

Installing Visual Studio LightSwitch

Managing the Offline Documentation

Appendix B Useful Resources

MSDN Resources

    LightSwitch Developer Center.

    LightSwitch How-Do-I Videos

    LightSwitch Blogs

    LightSwitch Forums

    Training Kit and Starter Kits

    Extensibility Center

    The Visual Studio Gallery.

    Code Samples

    Social Networks.

Community Resources.

    Visual Studio LightSwitch Help Website.

    LightSwitch Video Training on MyVBProf.com

    The CodeProject


    Italian LightSwitch Tips & Tricks Community.

    Other LightSwitch Blogs and Websites.

Third-Party Extensions

    Document Toolkit for LightSwitch.

    RSSBus Data Providers

    Infragistics NetAdvantage Light Edition

9780672335532   TOC   1/26/2012


Submit Errata

More Information

InformIT Promotional Mailings & Special Offers

I would like to receive exclusive offers and hear about products from InformIT and its family of brands. I can unsubscribe at any time.


Pearson Education, Inc., 221 River Street, Hoboken, New Jersey 07030, (Pearson) presents this site to provide information about products and services that can be purchased through this site.

This privacy notice provides an overview of our commitment to privacy and describes how we collect, protect, use and share personal information collected through this site. Please note that other Pearson websites and online products and services have their own separate privacy policies.

Collection and Use of Information

To conduct business and deliver products and services, Pearson collects and uses personal information in several ways in connection with this site, including:

Questions and Inquiries

For inquiries and questions, we collect the inquiry or question, together with name, contact details (email address, phone number and mailing address) and any other additional information voluntarily submitted to us through a Contact Us form or an email. We use this information to address the inquiry and respond to the question.

Online Store

For orders and purchases placed through our online store on this site, we collect order details, name, institution name and address (if applicable), email address, phone number, shipping and billing addresses, credit/debit card information, shipping options and any instructions. We use this information to complete transactions, fulfill orders, communicate with individuals placing orders or visiting the online store, and for related purposes.


Pearson may offer opportunities to provide feedback or participate in surveys, including surveys evaluating Pearson products, services or sites. Participation is voluntary. Pearson collects information requested in the survey questions and uses the information to evaluate, support, maintain and improve products, services or sites, develop new products and services, conduct educational research and for other purposes specified in the survey.

Contests and Drawings

Occasionally, we may sponsor a contest or drawing. Participation is optional. Pearson collects name, contact information and other information specified on the entry form for the contest or drawing to conduct the contest or drawing. Pearson may collect additional personal information from the winners of a contest or drawing in order to award the prize and for tax reporting purposes, as required by law.


If you have elected to receive email newsletters or promotional mailings and special offers but want to unsubscribe, simply email information@informit.com.

Service Announcements

On rare occasions it is necessary to send out a strictly service related announcement. For instance, if our service is temporarily suspended for maintenance we might send users an email. Generally, users may not opt-out of these communications, though they can deactivate their account information. However, these communications are not promotional in nature.

Customer Service

We communicate with users on a regular basis to provide requested services and in regard to issues relating to their account we reply via email or phone in accordance with the users' wishes when a user submits their information through our Contact Us form.

Other Collection and Use of Information

Application and System Logs

Pearson automatically collects log data to help ensure the delivery, availability and security of this site. Log data may include technical information about how a user or visitor connected to this site, such as browser type, type of computer/device, operating system, internet service provider and IP address. We use this information for support purposes and to monitor the health of the site, identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents and appropriately scale computing resources.

Web Analytics

Pearson may use third party web trend analytical services, including Google Analytics, to collect visitor information, such as IP addresses, browser types, referring pages, pages visited and time spent on a particular site. While these analytical services collect and report information on an anonymous basis, they may use cookies to gather web trend information. The information gathered may enable Pearson (but not the third party web trend services) to link information with application and system log data. Pearson uses this information for system administration and to identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents, appropriately scale computing resources and otherwise support and deliver this site and its services.

Cookies and Related Technologies

This site uses cookies and similar technologies to personalize content, measure traffic patterns, control security, track use and access of information on this site, and provide interest-based messages and advertising. Users can manage and block the use of cookies through their browser. Disabling or blocking certain cookies may limit the functionality of this site.

Do Not Track

This site currently does not respond to Do Not Track signals.


Pearson uses appropriate physical, administrative and technical security measures to protect personal information from unauthorized access, use and disclosure.


This site is not directed to children under the age of 13.


Pearson may send or direct marketing communications to users, provided that

  • Pearson will not use personal information collected or processed as a K-12 school service provider for the purpose of directed or targeted advertising.
  • Such marketing is consistent with applicable law and Pearson's legal obligations.
  • Pearson will not knowingly direct or send marketing communications to an individual who has expressed a preference not to receive marketing.
  • Where required by applicable law, express or implied consent to marketing exists and has not been withdrawn.

Pearson may provide personal information to a third party service provider on a restricted basis to provide marketing solely on behalf of Pearson or an affiliate or customer for whom Pearson is a service provider. Marketing preferences may be changed at any time.

Correcting/Updating Personal Information

If a user's personally identifiable information changes (such as your postal address or email address), we provide a way to correct or update that user's personal data provided to us. This can be done on the Account page. If a user no longer desires our service and desires to delete his or her account, please contact us at customer-service@informit.com and we will process the deletion of a user's account.


Users can always make an informed choice as to whether they should proceed with certain services offered by InformIT. If you choose to remove yourself from our mailing list(s) simply visit the following page and uncheck any communication you no longer want to receive: www.informit.com/u.aspx.

Sale of Personal Information

Pearson does not rent or sell personal information in exchange for any payment of money.

While Pearson does not sell personal information, as defined in Nevada law, Nevada residents may email a request for no sale of their personal information to NevadaDesignatedRequest@pearson.com.

Supplemental Privacy Statement for California Residents

California residents should read our Supplemental privacy statement for California residents in conjunction with this Privacy Notice. The Supplemental privacy statement for California residents explains Pearson's commitment to comply with California law and applies to personal information of California residents collected in connection with this site and the Services.

Sharing and Disclosure

Pearson may disclose personal information, as follows:

  • As required by law.
  • With the consent of the individual (or their parent, if the individual is a minor)
  • In response to a subpoena, court order or legal process, to the extent permitted or required by law
  • To protect the security and safety of individuals, data, assets and systems, consistent with applicable law
  • In connection the sale, joint venture or other transfer of some or all of its company or assets, subject to the provisions of this Privacy Notice
  • To investigate or address actual or suspected fraud or other illegal activities
  • To exercise its legal rights, including enforcement of the Terms of Use for this site or another contract
  • To affiliated Pearson companies and other companies and organizations who perform work for Pearson and are obligated to protect the privacy of personal information consistent with this Privacy Notice
  • To a school, organization, company or government agency, where Pearson collects or processes the personal information in a school setting or on behalf of such organization, company or government agency.


This web site contains links to other sites. Please be aware that we are not responsible for the privacy practices of such other sites. We encourage our users to be aware when they leave our site and to read the privacy statements of each and every web site that collects Personal Information. This privacy statement applies solely to information collected by this web site.

Requests and Contact

Please contact us about this Privacy Notice or if you have any requests or questions relating to the privacy of your personal information.

Changes to this Privacy Notice

We may revise this Privacy Notice through an updated posting. We will identify the effective date of the revision in the posting. Often, updates are made to provide greater clarity or to comply with changes in regulatory requirements. If the updates involve material changes to the collection, protection, use or disclosure of Personal Information, Pearson will provide notice of the change through a conspicuous notice on this site or other appropriate way. Continued use of the site after the effective date of a posted revision evidences acceptance. Please contact us if you have questions or concerns about the Privacy Notice or any objection to any revisions.

Last Update: November 17, 2020