Contents
Part I: Introducing LightSwitch
Chapter 1: Introducing LightSwitch
Understanding LightSwitch’s Architecture
Introducing the Model-Centric Architecture
Understanding MVVM (Model-View-ViewModel)
Walkthrough: Creating a LightSwitch Project
Chapter 2: Setting Up Your Data
Choosing Where to Store Your Data
What Are Entities and Properties?
Storing Numbers (Double and Decimal Types)
Storing Numbers (Integer Types)
Using LightSwitch Business Types
Storing Web Addresses and Percentage Values
Examining What Happens in SQL Server
Choice List Versus Related Tables
Defining One-to-Many-Type Relationships
How Relationships Are Defined in SQL Server
Defining Self-Referencing Relationships
Defining Many-to-Many Relationships
Determining How Child Records Are Deleted
Attaching to an Existing Database
Defining Relationships between Data Sources
Calculating Dates with Computed Properties
Summarizing Child Records with Computed Properties
Returning Images with Computed Properties
Sorting and Filtering by Computed Properties
Chapter 3: Building HTML Applications
Walkthrough 3-1. Creating an Application
Understanding Top-Level Screen Layout
Using the Screen Designer Toolbar
Laying Out Your Screen with Group Controls
Showing/Editing Email or Web Addresses
Building a Navigation Structure
Configuring the Navigation Menu
Navigating to Different Screens
Chapter 4: Creating Desktop Applications
What Are the Benefits of Desktop Applications?
Walkthrough 4-1. Creating New Data Screens
Grouping and Laying Out Controls
Displaying Data Using Data-Item Containers
Using the Auto-Complete Box Control
Using the Modal Window Picker Control
Displaying Static Text and Images
Styling Labels and Static Text Controls
Using the Data Grid and Data List Controls
Creating an Editable Grid Screen
Configuring Data Grid Settings
Setting Data Grid Header Buttons
Creating a List and Details Screen
Walkthrough 4-2. Using Details Screens
Setting Application Properties
Introduction to Data Retrieval
LightSwitch Queries Always Return Entities
Understanding the Query Pipeline
Using LightSwitch’s Default Queries
Creating Queries Based on Entities
Comparing Against Other Fields/Properties
Passing Arguments into a Query
Sorting Data Grids in Desktop Applications
Walkthrough: Working with Queries
Chapter 6: Writing Data-Access Code
Retrieving Single Records by ID Value
Working with Records and Nullable Data Types
Walkthrough 6-1: Client-Side Data-Access Code
Working with the Save Pipeline
Walkthrough 6-2: Working with Change Sets
Managing Transactions in LightSwitch
Walkthrough 6-3: Creating Transactions in the Save Pipeline
Displaying a Data-Conflict Screen
Walkthrough 6-4: Handling Conflicts in Code
Understanding Validation in LightSwitch
How Client Validation Works in Desktop Clients
How MVVM Applies to Validation
Defining Simple (Predefined) Validation Rules
Writing Custom Property Validation
Identifying Where Validation Runs
Creating Validation Rules and Warnings
Comparing against Other Properties
Mandating Data with Conditions
Validating Patterns with Regular Expressions
Checking against Child Collections
Validating Data at the Database
Walkthrough 7-1. Enforcing Data Rules
Enforcing Uniqueness and Preventing Duplicates
Validating Deletions on the Server
Chapter 8: Refinining HTML Clients Screens with JavaScript/CSS
Performing Screen Tasks with JavaScript
Hiding Controls and Setting Screen Titles
Displaying Custom Content on Screens
Walkthrough 8-1. Confirming Actions with Popups
Running Code When Data Changes
Displaying Data with Custom Controls
Editing HTML Data with Custom Controls
Customizing the Appearance of Your Application
Walkthrough 8-2. Customizing the UI
Chapter 9: Enhancing Desktop Screens with .NET Code
Adding Code to Your Application
Displaying Custom Text and Information
Accessing Grid and List Values
Setting the Screen Title in Code
Opening Screens from Buttons or Links
Adding Unbound Auto-Complete Boxes
Passing Arguments into Screens
Showing MessageBox and InputBox alerts
Finding Controls Using FindControl
Referencing the Underlying Silverlight Control
Handling Silverlight Control Events
Finding Out Which Thread Your Code Is Executing On
Understanding When to Execute Code on a Different Thread
Using PropertyChanged on a New Data Screen
Using PropertyChanged on a Details Screen
Walkthrough: Practical Screen Enhancements
Creating a Continuous New Data Screen
Part IV: Refining Your Application
An Overview of Built-In Search
Walkthrough 10-1. Building Custom Search
Filtering by Related Child Items
Matching Multiple Words (Optionally)
Walkthrough 10-2. Opening a Search Screen
Chapter 11: Building Practical Application Features
Adding File Support to HTML Client Applications
Adding File Support to Desktop Client Applications
Assigning and Unassigning Self-Joined Data
Creating Screens to Work with Single-Row Tables
Nesting Data-Selection Controls
Integrating with Mapping Systems
Showing Aggregate Counts/Sums/Averages
Chapter 12: Supporting Multiple Languages
Preparing an Application for Localization
Testing a Localized Application
Translating .NET Server Messages
Localizing HTML Client Resources
Localizing Screen Titles and Menu Items
Localizing JavaScript Messages
Localizing Screen Titles and Menu Items
Localizing Silverlight .NET Code
Chapter 13: Creating and Using Custom Controls
Binding Data to Custom Controls
Binding Data Collections to Custom Control
Converting Values When Data Binding
Creating a Custom Silverlight Control
Understanding Dependency Properties
Creating a New Control and Dependency Property
Binding Dependency Properties to the Data Context
Adding the Duration Control to a Screen
Calling Custom Control Methods via Dependency Properties
Calling Screen Code from a Custom Control
Part V: Extending the Reach of Your Data
Chapter 14: Optimizing Data Connectivity with RIA Services
The History behind RIA Services
Creating an RIA Services Project
Creating a Domain Service Class
Retrieving a Connection String from web.config
Chapter 15: Sharing Data with OData
Finding Third-Party Data Sources to Use
Determining Connection Settings
Connecting to an OData Data Source
Understanding Default Data-Source Options
Exposing Your LightSwitch Data Via OData
Finding Your Application’s Endpoint URL
Connecting to LightSwitch Data from Excel
Connecting to LightSwitch Data from .NET
Connecting to LightSwitch from Other Platforms
Using ASP.NET to Create Reports
Showing Grid Data on a Web Form
Securing and Deploying Reports
Using Microsoft Reporting Services
Installing the Report Designer Components
Using the Report Viewer Control
Linking Reports from Desktop Applications
Opening Reports in a New Browser Window
Displaying Reports inside LightSwitch Screens
Linking Reports from HTML Client Applications
Displaying Content inside an iframe
Chapter 17: Generating Office Documents
Performing Mail Merges with Word
Using Configuration Settings to Save Credentials
Creating a Reusable Email Class
Initiating Emails from LightSwitch Clients
Sending Messages from HTML Client Applications
Sending Messages from Desktop Applications
Sending Mail with Microsoft Outlook
Part VII: Extending LightSwitch
Chapter 19: Creating Control Extensions
Installing LightSwitch Extensions
Using the Many-to-Many Data Control
Preparing Your Computer to Develop Extensions
Understanding Custom Control Types
Specifying Which Data Types to Support
Supporting the FindControl Method
Optimizing Controls for Data-Grid Use
Retrieving Height, Size, and Property Settings
Running and Deploying Your Extension
Setting Product/Installation Attributes
Creating a Detail Control (ComboBox)
Setting the Control’s Metadata
Finding the Summary Property for an Entity
Creating Custom Property Editors
Customizing Visual Studio’s Property Editor
Creating a Custom Control Editor
Linking Your Property with the Editor
Customizing the Runtime Designer
Creating a Group Control Extension
Setting the Visibility of Labels
Creating a Command Control Extension
Chapter 20: Creating Data and Presentation Extensions
Creating a Business Type Extension
Associating Custom Controls with Business Types
Associating Validation Logic with a Business Type
Defining Property Sheet Attributes
Creating Custom Property Editor Windows
Creating a Custom Shell Extension
Defining the Look of Your Shell
Displaying Your Application’s Logo
Adding Code That Supports Our Custom Shell
Setting the Name and Description
Creating a Custom Theme Extension
Creating a Screen Template Extension
Creating More Complex Screen Templates
Creating an HTML Screen Template Extension
Creating a Data-Source Extension
Creating the Data Service Class
Using the Data-Source Extension
Part VIII: Securing Your Application
Chapter 21: Authenticating Your Users
Choosing an Authentication Method
Enabling Windows Authentication
Understanding Where User Details Are Stored
Changing the Password Complexity Rules
Changing Password Encryption Settings
Sharing Forms Authentication Data with ASP.NET
Allowing Users to Log Out of Desktop Web Applications
Chapter 22: Authorizing Your Users
Creating an Application Administrator
Applying Table-Level Access Control
Applying Query-Level Permissions
Securing HTML Client Applications
Associating Logins with Your Data
Opening Screens Conditionally at Login
Restricting Row-Level Access to Data
Setting Screen Control Properties by Permission
Allowing Users to Bypass Validation
Part IX: Going Live with Your Application
Chapter 23: Deploying Applications
Getting Started with Deployment
Choosing an Application Topology
Choosing Whether to Publish or Package
Digital Signature/Certificate Page
Installing the .NET 4.6 Framework
Setting Up IIS on Windows Server 2012/2008
Setting Up IIS on Windows 7 and Above
Configuring the Web Deploy Tool
Setting Up IIS Application Pools
Configuring SQL Server for Windows Authentication
Configuring Secure Sockets Layer (SSL)
Installing a Two-Tier Desktop Application
Installing a Three-Tier Application in IIS
Troubleshooting Deployment Errors
Connecting Visual Studio to Azure
Completing the Publishing Process
Appendix B: Data Type Identifiers
Appendix C: Using Properties in Custom Controls