Introduction

When I look back at the time that I have spent with LightSwitch, the product almost feels like a child of mine. I started using LightSwitch during the beta version when the product was in its infancy. Through the years, I’ve seen LightSwitch grow to be the mature product that it is today.

The early years were exciting. The concept was revolutionary, and there was a great buzz around the product. However, the documentation was poor, which inspired me to write the first edition of this book. I wanted to share my experience and to help developers avoid making the same mistakes that I made.

As developers began using LightSwitch and as market conditions changed, the product adapted to meet the changing environment. As an example, the first version of LightSwitch employed RIA services as the communication channel between the client and server. In 2012, Microsoft rewrote this part of LightSwitch to use OData instead. Another significant feature that Microsoft added in 2012 was the HTML client. This enables you to build HTML5-compatible applications that are optimized for touchscreen and mobile devices.

In subsequent releases, Microsoft improved several other areas of LightSwitch. A notable example is the improvements to the Visual Studio design environment. Early developers will remember how Visual Studio provided two views of a solution: a simplified logical view and a more advanced file view. In 2013, Microsoft replaced this with a simplified single view. Today, Visual Studio also provides much better IntelliSense and debugging support, particularly for JavaScript—an area for which support has previously been weak. Another significant addition was the Server Application Context. This feature makes it possible to execute data-access code on the server, outside the context of a LightSwitch application. All of this illustrates how LightSwitch has evolved into a far more powerful product.

In recent times, Microsoft has not been as proactive in further developing LightSwitch. Some developers are concerned about this, but I see this as a sign of a mature product. LightSwitch does everything that Microsoft intended it to do, and there is little more they can profitably add. If you’re just starting out with LightSwitch, my view is that now is a great time to begin. You can be confident that you’re working with a stable and mature product that has been tested by thousands of developers. There are few competing products that can match the capabilities that LightSwitch offers.

I’ve personally gained a lot from LightSwitch. With the help of LightSwitch, I’ve built some great applications with minimal time and effort. Through the work of this book, I’ve also had the chance to work with some really smart people in the Microsoft Visual Studio team.

By reading this book, I hope that you can attain similar rewards and develop some great applications at the same time.

Who This Book Is For

This book is designed for readers who want to build data-driven business applications quickly. You don’t need to have any prior knowledge of LightSwitch, but it helps if you know a little about .NET and database development in general.

How This Book Is Organized

If learning LightSwitch seems like an enormous task, don’t worry! You might have heard of the Pareto Principle, which also goes by the name of the 80/20 rule. This rule states that in most situations, 20% of something causes 80% of the results.

If you apply the Pareto Principle to this book, it suggests that you can accomplish 80% of what you want to accomplish by reading less than four chapters. And, in fact, the first four chapters highlight the key topics that are all you need in order to build an application that’s almost 80% complete.

By the end of Chapter 4, you’ll understand how to create data tables and attach to external data. You’ll know how to build applications that include Data Entry screens and navigation controls. The type of data entry screens I’ll describe will include screens that show lists of data and those that enable the entry and display of single records. You’ll also discover how to provide drop-down controls to enable users to make selections during data entry. In short, you’ll know how to build a working business application with enough functionality to perform most basic tasks. In the next part of the book, I’ll show you how to write code and queries. This includes .NET code that runs on the server and Silverlight desktop client, and JavaScript code that runs on HTML client applications.

Unless you want to create an application that’s completely isolated from other systems, it’s useful to know how to attach to unusual data sources and how to share your LightSwitch data with other applications. You’ll discover how to do this through RIA services and OData.

You can extend your Silverlight applications through custom controls and extensions, and you’ll find an entire section of the book devoted to this topic.

The remaining chapters of the book show you how to build reports, integrate with email systems, and deploy your application.

The Sample Application

Most of the chapters include code samples that refer to a Help Desk application. The purpose of this application is to relate the technical content in the book to a real-life scenario that you can more easily understand.

The Help Desk application is typical of the applications that you can build with LightSwitch. Its features are simple enough to understand, yet complex enough to show off the more advanced features of LightSwitch. It is designed to help companies manage problems, and it’s especially suitable for departments that deal with technical support issues. It allows users to record the actions they carry out to resolve a problem while giving managers an overview of all current issues.

Figure I-1 shows a screen from this application and illustrates some of the features that I’ll cover in this book.

9781484207673_FigBookFrontmatter-02.jpg

Figure I-1 Typical screen from the Help Desk application

Figure I-1 shows the Data Entry screen through which users can enter help-desk issues. They can set the user that the issue relates to and allocate an engineer to the record. The Data Entry screen allows users to respond to the issue, attach documents, register feedback, and record the amount of time that engineers spend on the task. To help you recreate this application, you can find a summary of the application’s tables in Appendix E.

Code Samples

LightSwitch supports C#, VB.NET, and JavaScript. This book includes code samples in all three languages. To make life simple, LightSwitch hides much of the complexity that’s associated with application design. When you want to write some code, you do so by clicking on a Write Code button that LightSwitch shows in its graphical designers. This button shows a list of events that you can handle. When you select one of the options in the list, LightSwitch opens a Code Editor window that you can use to author your code.

When you’re starting out with LightSwitch, it isn’t always obvious where your code is stored. To add some clarity, each code listing includes a file location, as shown in Listing I-1.

For both the VB and C# examples in Listing I-1, the File heading specifies the file name and path. In this example, HelpDeskVB and HelpDeskCS prefixes identify the name of your LightSwitch application. The Server part indicates that the code refers to the Server project. This piece of information is useful, because it informs you that the code runs on the server rather than on the client. (You’ll learn all about this in Chapter 1.) The next part of the file heading, DataSourcesApplicationData, indicates the folder in the Server project that contains the code file. Finally, _ApplicationDataService.vb and _ApplicationDataService.cs refer to the name of the VB or C# file that the listing shows.

If a piece of code requires you to reference a .NET namespace, the code listing will show the necessary import (VB.NET) or using (C#) statements. Be sure to add these statements to the top of your code file.

Many of the code samples include numeric symbols to help you locate specific lines in a code listing. For example, line image defines a comment, whereas line image declares a variable. There’s obviously no need to enter these numeric symbols when you recreate this code for real!

As in all books, the length of a code line can exceed the width of the page. In most cases, I’ve put line breaks in places that still allow the code to compile, but in some circumstances this isn’t possible. Notable examples include namespace declarations in XAML files and VB.NET keywords like inherits and implements. If your application doesn’t compile, it’s worth checking your code for extraneous line breaks.

Tips/Notes/Cautions

This book includes callouts with tips, notes, and cautions. Tips are helpful hints or pieces of information that may be particularly interesting. Notes provide you with nonessential—yet interesting—additional information about a particular topic. Cautions alert you to anything that might be detrimental to your work or could cause damage.

Comments and Errata

Although my editors and I have tried to be as accurate as possible, mistakes do sometimes happen (particularly with a book of this length). If you have any feedback or want to report any bugs, please visit the official page for this book at the Apress website:

http://www.apress.com/9781484207673

This page also shows any mistakes that we’ve found following the publication of this book.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset