Inside Data 53

 By Graham Keitch

Graham Keitch finds out what Visual Studio LightSwitch 2011 has to offer the database developer.

HardCopy Issue: 53 | Found In: Database | Published: 14/09/2011 | Last Revision: 21/11/2011

In the last issue of Inside Data, I wrote about Oracle Application Express (APEX) in the context of its support for Microsoft Office. In July 2011 Microsoft released a similar tool based largely on Silverlight technology, Visual Studio LightSwitch 2011. The two products are not directly comparable but share common objectives in simplifying the development of business applications, so it might be timely to look at the Microsoft offering. As any database developer knows, building user interfaces for data-centric applications involves a lot of repetitive coding. LightSwitch takes care of this, leaving the developer to concentrate on the unique business logic. The ability to search, sort, rearrange grids and export data is prebuilt into LightSwitch. So too are the components for handling basic data operations and validation. As part of the Visual Studio and .NET environments, it permits the development of conventional classes and can reference external assemblies. It’s a valuable addition to the Microsoft stack, working alongside Silverlight, SQL Server, RIA Services, the Entity Framework and IIS. LightSwitch also targets Windows Azure and SQL Azure for cloud projects.

Denali and Juneau

Microsoft is also planning to release a more advanced set of database developer tools to coincide with the next release of SQL Server (codenamed ‘Denali’). This will be SQL Server Developer Tools (SSDT), currently known as ‘Juneau’.

SSDT is intended for both administrators and developers. It offers new capabilities in a single environment to compile, refactor and deploy databases to specific editions of SQL Server and SQL Azure. The tools make it easy to migrate on-premise SQL Server schemas to the cloud on SQL Azure and develop and maintain databases across both platforms. SSDT targets all editions of SQL Server 2005 through to 2008 R2, SQL Server ‘Denali’ and SQL Azure.

The basic steps for building an application involve creating a project, defining the data and creating screens. A LightSwitch project stores and organises the components of your application. When creating a new project, the first step is to specify whether it will be a Windows desktop application that will run from the Start menu or a web application that will run in a browser. LightSwitch supports Visual Basic and Visual C# and once specified, your chosen language will be used throughout the project. The next step involves defining the data to be used. You create a table (data entity) and use the Data Designer to specify field properties and data types. Entities are created using the built-in application database or by importing data from an external source. The data you enter and save in your application is stored in an internal database. LightSwitch uses custom business types to specify complex data typically used in business applications such as telephone numbers and e-mail addresses. Many business types are already defined and the set is extensible. This reduces the amount of code that has to be written and simplifies formatting in the user interface. You can create relationships between entities, including those from different sources, and this is much easier than with Microsoft Access. A graphical designer is used to create queries which can be modified further by code.

Visual Studio LightSwitch application architecture
The basic three-tier architecture that lies behind a LightSwitch application.

Screens or forms based on predefined templates determine how LightSwitch displays information and enables the user to enter, retrieve and edit data. To bind data to a screen, you specify the entities or queries to be displayed. The default settings are usually sufficient although the Screen Designer facilitates customisation. This allows you to change the field properties and layout. You have to run the application to see the screen although you can make changes at runtime. Most applications need multiple screens that combine data from disparate sources, or change the display based on certain conditions. This is all handled by LightSwitch. The extensibility features allow you to change the appearance and layout of applications by applying themes, custom controls and shell extensions. Third party plugins from Infragistics and ComponentOne provide additional functionality, again reducing the need for code. Validation rules such as required fields and string lengths are built into the screens at runtime. For more complex validations based on business logic, you will have to write code. While testing the application, changes can be made to the user interface directly in the running application. By impersonating a role under debug permissions, you can test authentication and authorisation. The application can be deployed using ClickOnce, which allows for future silent updates. LightSwitch, in common with other Microsoft developer tools, is licensed on a per developer basis. A free runtime license is included for LightSwitch applications only.

Share and Bookmark  

Comments

Be the first to comment about this article...

Leave a comment

You must login to place comments.