Here we will see how to create a Summary Property using LightSwitch Visual Studio 2012.
The following is the procedure to create a Summery Property in LightSwitch.
Step 1
Open the LightSwitch Application in Visual Studio 2012 and go to the Solution Explorer.
Right-click on "Data Sources" and choose "Add Table".
The table appears in the table designer window. Insert the records in the following table.
Step 2
In the table designer, add the Computed Property from the menu bar as shown in the figure.
The computed property will be added to the table. Provide some name to the computed property.
This will set the "Is Computed" property in the property window and click on the Edit Method link.
Write the following code in the Code Designer:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.LightSwitch;
namespace LightSwitchApplication
{
public partial class Emp
{
partial void FullName_Compute(ref string result)
{
result = this.FName + "," + this.LName;
}
}
}
Step 3
In order to set the "Summary Property", select the table name and then go to the property window, under the Summary Property select the "Full Name" under the dropdown list of the summary properties.
Step 4
Right-click on Screens and choose "Add Screen".
The Add New Screen dialog box appears. Select the "List and Details Screen" from the Screen Template, under screen information, choose "Emp" under screen data and provide some name to the Screen and click OK button.
The Screen Designer appears as shown below.
Step 5
From the screen designer, select the Full Name, and after that go to the property window and mark the "Show as Link "checkbox as checked from the property window.
Press F5 in order to run the application. Click on the "+" button and provide the information as shown below.
We will see that the data will be added as shown.