LightSwitch is a Rapid Development environment that will allow technical and somewhat-technical people the ability to create light weight Line of Business applications. While many developers don’t think LightSwitch will be useful for creating apps, we think it can be very beneficial to use in the right circumstances.
Microsoft® Visual Studio® LightSwitch™ is a new streamlined development environment for designing data-centric business applications and helps you to build data-centric applications quickly, through visual means. LightSwitch business applications are multi-tiered, featuring a client application and a combination of LINQ, WCF RIA Services and the Entity Framework to implement the application services tier.
Benefits of using LightSwitch?
There are many benefits of using LightSwitch as shown in the below list
- You can create an application with just few clicks and no code or coding only in the data models or substantial code within all parts of the application.
- Based on permission, LightSwitch support distinct audiences end-users (View & Edit Data), administrative (maintain certain master data) and Super-users (granted access to most or all of the data and functionality).
- Support built-in Business Types include like (Email, PhoneNumber, money,..etc), and partners can create new Business Types.
- Enable Debug mode, and allows the screen to be edited interactively while the application is running.
- Enable adding custom business rules to any field in the screen.
- ou can create custom controls and embed sophisticated behaviors there.
- LightSwitch produces desktop applications or pulls down and executed implicitly by navigating to a URL.
- Enables you to deploy your LightSwitch on Cloud and Azure as simple as running a wizard.
Start building the App
Now let’s start building our application, I am going to list every thing in details starting from opening Visual studio 2012 until running the application. we will go throw the following steps.
Step 1 : Creating the Application
Creating new LightSwitch application is very simple, if you’re familiar with any old version of Visual Studio as follows:
Open VS 2012 –> New project –> Select LightSwitch from project Template list –> Select LightSwitch application (c#), and finally we will write the project name LighSwitchsubscriptionApp –> press Ok
Step 2 : Creating & Defining Data tables and relationships
The start point to LightSwitch application is creating Data Table and you can do this task through four ways:
- Click the Create new table link in the start up project page “Start with data” which called [you project name] Designer
- Go to Visual Studio menu bar Select Project –> Add table
- Right click Project Name in solution explorer then select Add table
- Connect to an exist data source published on (Database, Sharepoint, OData Services, WCF RIA Service) as mentioned in step 2 and 3, but select Add data source instead of Add Table option, and create Subscriber table as shown in below figure
The above picture, it contains Useremail field with Data type Email, this is one of the new features of LightSwitch , that you can create new field with new Business Types like (Email, Money, Phone, web address).
- In addition, you can add New filed of static choice list by selecting choicelist link from right side properties of any string field, for example, we will create choicelist for Gender(male, female).
- Usually any registration module needs dropdown list of country field, but using LightSwitch makes the difference for you, we are not going to create new control and write code to bind this control from database, we are going to create new table of countries and link it to our Subscriber table and link these two tables, by following the below steps:
- Create new table called Country with one columns(contryDesc).
- Then click Relationshin, button in the toolbar.
- Finally build the relation between the subscriber and country tables as shown below.
Step 3 : Building Screens & Running the Application
Now, we are getting ready to Build the screens corresponding to Entities, simply you click the Screen button from the toolbar on the subscriber & Countries Table Design forms, this will open Add ‘New screen’ Dialog then select the highlighted option showing in figure below, and finally press Ok button.
- Repeat same process above for country entity.
- Finally, we can run the application by pressing f5 key, we will see screen as shown in figure below:
- Now, let’s go a head and review above screen as listed below:
Box 1 ,represent two tabs for all entity screens we have created .
Box 2 ,represent all actions available for this gridview Add, Delete, Edit, Search .
Box 3, represent the Dialog screen that opens when you select Add button.
Box 4, Showing Required fields marked as Bold.
Box 5, Showing Country list that I have entered in country entity.
Box 6, includes main actions for this screen ( Save , Refresh).
- There is another very important feature here, as you can see on right bottom of the screen link [Design Screen], this link allows you to edit the screen Design on the execution mode, if and only if, you have run the application in Debug mode.
- Eventually, we did not finish all features of LightSwitch, but we have other features that I will list them soon in other posts, I was just trying to show the power of using Lightswitch without writing any line of code.