Visual Studio LightSwitch 2015, Second Edition

Book description

In this fully updated second edition, award-winning author Tim Leung explains how to build data-centric business applications for the desktop, cloud, web, and mobile devices in just a few clicks—with no code required—using Visual Studio Lightswitch 2015. This book explains the basics of Visual Studio Lightswitch 2015 plus new features and key advanced topics that every Microsoft developer needs to know to create modern data services and build clients that can run on multiple devices.

Visual Studio LightSwitch 2015 is a rapid application deployment tool that simplifies and shortens the time needed to develop business applications. The basics are very easily understood but more advanced users will hunger for more. How do you design complex layouts? How do you query data using LINQ and other syntax structures? How do you secure your application against malicious use? Visual Studio LightSwitch 2015 answers these questions and more as author Tim Leung—winner of a Microsoft 2011 Community Contributor Award for his LightSwitch expertise—covers this breakthrough product in detail. For serious developers building, enhancing, and deploying advanced business applications using LightSwitch makes sense because they can benefit from the elegance, convenience, and cost savings afforded by rapid application development before going beyond the "click-and-you're-done" interface to include the extra value and depth of coding expertise that their clients value.

Table of contents

  1. Cover
  2. Title
  3. Copyright
  4. Contents at a Glance
  5. Contents
  6. About the Author
  7. About the Technical Reviewers
  8. Acknowledgments
  9. Introduction
  10. Part I: Introducing LightSwitch
    1. Chapter 1: Introducing LightSwitch
      1. What’s New in 2015
      2. Understanding LightSwitch’s Architecture
        1. The Data Tier
        2. The Logic Tier
        3. The Presentation Tier
      3. Introducing the Model-Centric Architecture
      4. Building Your Application
      5. Understanding MVVM (Model-View-ViewModel)
      6. Walkthrough: Creating a LightSwitch Project
      7. Summary
    2. Chapter 2: Setting Up Your Data
      1. Choosing Where to Store Your Data
      2. What Are Entities and Properties?
      3. Creating Tables (Entities)
      4. Creating Fields (Properties)
        1. Storing Textual Data
        2. Storing Numbers (Double and Decimal Types)
        3. Storing Numbers (Integer Types)
        4. Formatting Numeric Fields
        5. Storing Images
        6. Storing Binary Data
        7. Storing Dates
        8. Ensuring Unique Values
        9. Changing Data Types
      5. Using LightSwitch Business Types
        1. Storing Email Addresses
        2. Storing Monetary Values
        3. Storing Phone Numbers
        4. Storing Web Addresses and Percentage Values
        5. Storing People Data
      6. Examining What Happens in SQL Server
      7. Creating Choice Lists
        1. Choice List Versus Related Tables
      8. Defining Relationships
        1. Defining One-to-Many-Type Relationships
        2. How Relationships Are Defined in SQL Server
        3. Defining Self-Referencing Relationships
        4. Defining Many-to-Many Relationships
        5. Determining How Child Records Are Deleted
      9. Attaching Existing Data
        1. Attaching to an Existing Database
        2. Attaching to SharePoint Data
        3. Deleting a Data Source
        4. Defining Relationships between Data Sources
      10. Creating Computed Properties
      11. Creating Summary Properties
        1. Calculating Dates with Computed Properties
        2. Summarizing Child Records with Computed Properties
        3. Returning Images with Computed Properties
        4. Sorting and Filtering by Computed Properties
      12. Summary
    3. Chapter 3: Building HTML Applications
      1. Building an HTML Application
        1. Creating Screens
        2. Walkthrough 3-1. Creating an Application
      2. Using the Screen Designer
        1. Understanding Top-Level Screen Layout
        2. Using the Screen Designer Toolbar
        3. Using Tabs
      3. Laying Out Your Screen with Group Controls
      4. Using Data Controls
        1. Showing/Editing String Values
        2. Working with Boolean Values
        3. Showing/Editing Date Values
        4. Showing/Editing Email or Web Addresses
        5. Showing Lists of Records
        6. Using Data Picker Controls
      5. Positioning Controls
      6. Setting Screen Properties
      7. Building a Navigation Structure
        1. Setting a Home Screen
        2. Configuring the Navigation Menu
        3. Navigating to Different Screens
        4. Adding Navigation Buttons
        5. Changing Button Icons
      8. Summary
    4. Chapter 4: Creating Desktop Applications
      1. What This Chapter Covers
      2. What Are the Benefits of Desktop Applications?
      3. Creating a Desktop Client
        1. Setting the Application Type
      4. Choosing a Screen Template
      5. Walkthrough 4-1. Creating New Data Screens
      6. Designing Screens
        1. Setting Screen Properties
        2. Grouping and Laying Out Controls
        3. Choosing Data Controls
        4. Displaying Data Using Data-Item Containers
      7. Using Data-Selection Controls
        1. Using the Auto-Complete Box Control
        2. Using the Modal Window Picker Control
      8. Displaying Static Text and Images
      9. Setting Control Appearances
        1. Positioning Control Labels
        2. Styling Labels and Static Text Controls
        3. Making Controls Read-Only
      10. Including Related Data Items
      11. Using the Data Grid and Data List Controls
      12. Creating an Editable Grid Screen
        1. Configuring Data Grid Settings
        2. Setting Data Grid Header Buttons
      13. Creating a List and Details Screen
      14. Creating a Search Screen
      15. Creating Details Screens
        1. Walkthrough 4-2. Using Details Screens
      16. Setting Application Properties
      17. Configuring Screen Navigation
      18. Designing Screens at Runtime
      19. Reducing Project Sizes
      20. Summary
  11. Part II: Working with Data
    1. Chapter 5: Quer?ying Your Data
      1. Introduction to Data Retrieval
        1. LightSwitch Queries Always Return Entities
      2. Understanding the Query Pipeline
      3. Using LightSwitch’s Default Queries
      4. Filtering and Sorting data
        1. Creating Queries Based on Entities
        2. Applying Filters
        3. Comparing Against Other Fields/Properties
        4. Passing Arguments into a Query
        5. Filtering by Global Values
        6. Modifying Screen Queries
      5. Sorting Data
        1. Sorting Data Grids in Desktop Applications
        2. Examining User-Setting Files
      6. Walkthrough: Working with Queries
        1. 5-1. Filtering Controls
        2. 5-2. Using Queries on Screens
      7. Summary
    2. Chapter 6: Writing Data-Access Code
      1. LightSwitch Data API
        1. Retrieving Single Records by ID Value
        2. Working with Records and Nullable Data Types
        3. Using JavaScript Promises
        4. Walkthrough 6-1: Client-Side Data-Access Code
        5. Executing Queries Remotely
      2. Working with the Save Pipeline
        1. Walkthrough 6-2: Working with Change Sets
      3. Managing Transactions in LightSwitch
        1. Understanding Transactions
        2. Walkthrough 6-3: Creating Transactions in the Save Pipeline
      4. Understanding Concurrency
        1. Displaying a Data-Conflict Screen
        2. Walkthrough 6-4: Handling Conflicts in Code
      5. Summary
    3. Chapter 7: Validating Data
      1. Understanding Validation in LightSwitch
      2. How Client Validation Works in Desktop Clients
        1. How MVVM Applies to Validation
      3. Defining Simple (Predefined) Validation Rules
      4. Writing Custom Property Validation
        1. Identifying Where Validation Runs
        2. Creating Validation Rules and Warnings
      5. Custom Validation Examples
        1. Comparing against Other Properties
        2. Mandating Data with Conditions
        3. Validating Patterns with Regular Expressions
        4. Checking against Child Collections
      6. Validating Data on the Client
        1. HTML Client Validation
        2. Desktop Client Validation
      7. Validating Data at the Database
      8. Walkthrough 7-1. Enforcing Data Rules
        1. Enforcing Uniqueness and Preventing Duplicates
        2. Validating Deletions on the Server
      9. Summary
  12. Part III: Writing ScreenCode
    1. Chapter 8: Refinining HTML Clients Screens with JavaScript/CSS
      1. Examining the JavaScript API
        1. Handling Screen Events
        2. API Objects
      2. Performing Screen Tasks with JavaScript
        1. Setting Default Screen Values
        2. Hiding Controls and Setting Screen Titles
      3. Displaying Custom Content on Screens
        1. Adding Custom Text on Screens
        2. Adding Custom HTML to Screens
      4. Using Popups
        1. Walkthrough 8-1. Confirming Actions with Popups
      5. Using Data-Binding Techniques
        1. Formatting Data
        2. Running Code When Data Changes
      6. Using Custom Controls
        1. Displaying Data with Custom Controls
        2. Editing HTML Data with Custom Controls
      7. Customizing the Appearance of Your Application
        1. Theming Your Application
        2. Bespoke Customization
      8. Walkthrough 8-2. Customizing the UI
        1. Creating Custom Navigation
        2. Creating Custom Buttons
      9. Summary
    2. Chapter 9: Enhancing Desktop Screens with .NET Code
      1. Adding Code to Your Application
        1. General Methods
        2. Access Control Methods
        3. Collection Methods
        4. Screen Property Methods
      2. Working with Code and Data
        1. Displaying Custom Text and Information
        2. Accessing Grid and List Values
        3. Setting the Screen Title in Code
      3. Setting Default Screen Values
      4. Navigating Screens
        1. Opening Screens from Buttons or Links
        2. Adding Unbound Auto-Complete Boxes
        3. Refreshing All Open Screens
        4. Passing Arguments into Screens
      5. Showing MessageBox and InputBox alerts
      6. Working with Controls
        1. Finding Controls Using FindControl
        2. Referencing the Underlying Silverlight Control
        3. Handling Silverlight Control Events
      7. Working with Threads
        1. Finding Out Which Thread Your Code Is Executing On
        2. Understanding When to Execute Code on a Different Thread
      8. Reacting to Data Changes
        1. Using PropertyChanged on a New Data Screen
        2. Using PropertyChanged on a Details Screen
      9. Walkthrough: Practical Screen Enhancements
        1. Creating a Continuous New Data Screen
        2. Designing an Add/Edit Screen
        3. Customizing Data-Grid Dialogs
      10. Summary
  13. Part IV: Refining Your Application
    1. Chapter 10: Searching Data
      1. An Overview of Built-In Search
      2. Walkthrough 10-1. Building Custom Search
        1. Defining a Search Query
        2. Creating the Search Screen
      3. Building Advanced Searches
        1. Introducing LINQ
      4. Practical Querying Examples
        1. Filtering by Related Child Items
        2. Exists, In
        3. Not Exists, Not In
        4. Filtering by Date Elements
        5. Top N Records
      5. String-Matching Examples
        1. Matching Non-Concurrent Words
        2. Matching Multiple Words (Optionally)
        3. Case Sensitivity
        4. Phonetic Searching
      6. Debugging Queries
      7. Walkthrough 10-2. Opening a Search Screen
      8. Summary
    2. Chapter 11: Building Practical Application Features
      1. Working with Files
        1. Adding File Support to HTML Client Applications
        2. Adding File Support to Desktop Client Applications
        3. Validating File Sizes
      2. Selecting Multiple Records
      3. Assigning and Unassigning Self-Joined Data
      4. Creating Screens to Work with Single-Row Tables
      5. Nesting Data-Selection Controls
      6. Working with Locations
        1. Picking Up GPS Locations
        2. Integrating with Mapping Systems
      7. Summarizing Data
        1. Showing Aggregate Counts/Sums/Averages
        2. Querying Data Remotely
        3. Merging Data
      8. Summary
    3. Chapter 12: Supporting Multiple Languages
      1. Introduction
        1. Supported Languages
      2. Preparing an Application for Localization
      3. Localizing Server Objects
        1. Translating Table Field Names
        2. Testing a Localized Application
        3. Translating .NET Server Messages
      4. Localizing HTML Client Resources
        1. Localizing Screen Titles and Menu Items
        2. Localizing JavaScript Messages
        3. Localizing Dates and Numbers
      5. Localizing Desktop Apps
        1. Localizing Screen Titles and Menu Items
        2. Localizing Silverlight .NET Code
      6. Summary
    4. Chapter 13: Creating and Using Custom Controls
      1. Using Custom Controls
        1. Specifying a Custom Control
        2. Binding Data to Custom Controls
        3. Binding Data Collections to Custom Control
        4. Converting Values When Data Binding
      2. Creating a Custom Silverlight Control
        1. Understanding Dependency Properties
        2. Creating a New Control and Dependency Property
        3. Binding Dependency Properties to the Data Context
        4. Adding the Duration Control to a Screen
        5. Calling Custom Control Methods via Dependency Properties
      3. Calling Screen Code from a Custom Control
      4. Summary
  14. Part V: Extending the Reach of Your Data
    1. Chapter 14: Optimizing Data Connectivity with RIA Services
      1. The History behind RIA Services
      2. Creating an RIA Services Project
        1. Creating a New Project
        2. Creating an Entity Class
        3. Creating a Domain Service Class
      3. Retrieving Data
      4. Retrieving a Connection String from web.config
      5. Updating Data
      6. Calling SQL Stored Procedures
      7. Consuming Your RIA Service
      8. Summary
    2. Chapter 15: Sharing Data with OData
      1. Introduction
      2. Using External Data Sources
        1. Finding Third-Party Data Sources to Use
        2. Determining Connection Settings
        3. Connecting to an OData Data Source
        4. Understanding Default Data-Source Options
      3. Exposing Your LightSwitch Data Via OData
        1. Finding Your Application’s Endpoint URL
        2. Querying OData
        3. Securing OData Feeds
      4. Consuming LightSwitch Data
        1. Connecting to LightSwitch Data from Excel
        2. Connecting to LightSwitch Data from .NET
        3. Connecting to LightSwitch from Other Platforms
      5. Summary
  15. Part VI: Getting Data Out
    1. Chapter 16: Creating Reports
      1. Introduction to Reporting
      2. Using ASP.NET to Create Reports
        1. Showing Grid Data on a Web Form
        2. Displaying Grids within Grids
        3. Creating Charts
        4. Securing and Deploying Reports
      3. Using Microsoft Reporting Services
        1. Installing Reporting Services
        2. Installing the Report Designer Components
        3. Creating Reports
        4. Deploying Reports
      4. Using the Report Viewer Control
      5. Linking Reports from Desktop Applications
        1. Opening Reports in a New Browser Window
        2. Displaying Reports inside LightSwitch Screens
        3. Printing Reports
      6. Linking Reports from HTML Client Applications
        1. Displaying Content inside an iframe
        2. Adding Hyperlinks
      7. Summary
    2. Chapter 17: Generating Office Documents
      1. Overview of Techniques
        1. Using the OpenXML SDK
        2. Performing COM Automation
        3. Performing Mail Merges with Word
      2. Creating Adobe PDF Documents
      3. Summary
    3. Chapter 18: Sending Email
      1. Overview to Sending Email
      2. Sending Email Notifications
        1. Using Configuration Settings to Save Credentials
        2. Creating a Reusable Email Class
        3. Sending the Email
      3. Initiating Emails from LightSwitch Clients
        1. Building an Email service
        2. Sending Messages from HTML Client Applications
        3. Sending Messages from Desktop Applications
      4. Sending Mail with Microsoft Outlook
      5. Summary
  16. Part VII: Extending LightSwitch
    1. Chapter 19: Creating Control Extensions
      1. Using LightSwitch Extensions
        1. Installing LightSwitch Extensions
        2. Using the Many-to-Many Data Control
      2. Preparing Your Computer to Develop Extensions
      3. Understanding Custom Control Types
      4. Creating Value Controls
        1. Specifying Which Data Types to Support
        2. Supporting the FindControl Method
        3. Setting the Control Icon
        4. Optimizing Controls for Data-Grid Use
        5. Retrieving Height, Size, and Property Settings
      5. Running and Deploying Your Extension
        1. Setting Product/Installation Attributes
      6. Creating a Detail Control (ComboBox)
        1. Setting the Control’s Metadata
        2. Finding the Summary Property for an Entity
      7. Creating Custom Property Editors
        1. Customizing Visual Studio’s Property Editor
        2. Preparing Your Project
        3. Creating a Custom Control Editor
        4. Linking Your Property with the Editor
        5. Customizing the Runtime Designer
      8. Creating a Group Control Extension
        1. Setting the Visibility of Labels
      9. Creating a Command Control Extension
      10. Summary
    2. Chapter 20: Creating Data and Presentation Extensions
      1. Introduction
      2. Creating a Business Type Extension
        1. Associating Custom Controls with Business Types
        2. Enforcing Validation
        3. Associating Validation Logic with a Business Type
        4. Defining Property Sheet Attributes
        5. Applying Validation Logic
        6. Creating Custom Property Editor Windows
        7. Using Your Business Type
      3. Creating a Custom Shell Extension
        1. Preparing Your Project
        2. Defining the Look of Your Shell
        3. Binding Data to Your Shell
        4. Displaying Your Application’s Logo
        5. Adding Code That Supports Our Custom Shell
        6. Managing Screens
        7. Executing Commands
        8. Performing Navigation
        9. Persisting User Settings
        10. Setting the Name and Description
        11. Using Your Custom Shell
      4. Creating a Custom Theme Extension
        1. Applying a Different Font
        2. Setting Different Colors
      5. Creating a Screen Template Extension
        1. Setting Template Properties
        2. Defining the Data-Source Type
        3. Generating Screen Controls
        4. Generating Screen Code
        5. Creating More Complex Screen Templates
      6. Creating an HTML Screen Template Extension
      7. Creating a Data-Source Extension
        1. Creating an Entity Class
        2. Creating the Data Service Class
        3. Using the Data-Source Extension
      8. Summary
  17. Part VIII: Securing Your Application
    1. Chapter 21: Authenticating Your Users
      1. Choosing an Authentication Method
        1. No Authentication
        2. Enabling Windows Authentication
        3. Forms Authentication
      2. Understanding Where User Details Are Stored
        1. Changing the Password Complexity Rules
        2. Changing Password Encryption Settings
        3. Sharing Forms Authentication Data with ASP.NET
        4. Allowing Users to Log Out of Desktop Web Applications
      3. Summary
    2. Chapter 22: Authorizing Your Users
      1. Applying Permissions
      2. Defining Permissions
      3. Creating an Application Administrator
      4. Managing Roles and Users
        1. Debugging Permission Code
      5. Securing Server Objects
        1. Applying Table-Level Access Control
        2. Applying Query-Level Permissions
      6. Securing Client Objects
        1. Securing HTML Client Applications
      7. Custom Authorization Examples
        1. Associating Logins with Your Data
        2. Opening Screens Conditionally at Login
        3. Restricting Row-Level Access to Data
        4. Setting Screen Control Properties by Permission
        5. Allowing Users to Bypass Validation
      8. Summary
  18. Part IX: Going Live with Your Application
    1. Chapter 23: Deploying Applications
      1. Getting Started with Deployment
        1. Choosing an Application Topology
        2. Choosing Whether to Publish or Package
        3. Setting Up Your Workstations
        4. Setting Up SQL Server
      2. Using the Publish Wizard
        1. Data Connections Page
        2. Prerequisites Page
        3. Security Page
        4. Digital Signature/Certificate Page
      3. Setting Up Your Web Server
        1. Installing the .NET 4.6 Framework
        2. Setting Up IIS on Windows Server 2012/2008
        3. Setting Up IIS on Windows 7 and Above
        4. Configuring the Web Deploy Tool
        5. Setting Up IIS Application Pools
        6. Configuring SQL Server for Windows Authentication
        7. Configuring Secure Sockets Layer (SSL)
      4. Installing the Packages
        1. Installing a Two-Tier Desktop Application
        2. Installing a Three-Tier Application in IIS
      5. Three-Tier Manual Deployment
      6. Deploying Data
      7. Updating an Application
      8. Troubleshooting Deployment Errors
        1. Tracing Your Application
      9. Deploying to Azure
        1. Connecting Visual Studio to Azure
        2. Selecting a Service Type
        3. Creating a Database
        4. Completing the Publishing Process
      10. Publishing to SharePoint
      11. Summary
    2. Appendix A: Culture Names
    3. Appendix B: Data Type Identifiers
    4. Appendix C: Using Properties in Custom Controls
    5. Appendix D: Custom Screen Template View IDs
      1. Desktop Client View IDs
      2. HTML Client View IDs
    6. Appendix E: Data Schemas
      1. Help Desk Tables
      2. External Tables
      3. Database Diagram
  19. Index

Product information

  • Title: Visual Studio LightSwitch 2015, Second Edition
  • Author(s):
  • Release date: December 2015
  • Publisher(s): Apress
  • ISBN: 9781484207666