Author: Richard Waddell Created: 5/5/2011 12:17 PM RssIcon
Richard Waddell - All About LightSwitch
By Richard Waddell on 2/8/2013 11:51 PM

 

image

LightSwitch provides for creating Data Sources in several ways. In the case of an existing database you would typically either specify the database itself or a WCF RIA Service.

image

But sometimes neither is feasible. I was confronted with a database with no primary keys and incredibly wide tables – so wide that I got error messages about it. And you can’t really do much with a database that has no primary keys. Also modifying the schema was not an option.

This actually turned out to be quite liberating. The reason we wanted to access the database outside of the legacy application it was designed for was to

  • Provide views of the data that the legacy application did not.
  • Add additional columns

By extracting the data into another database we could

  • Eliminate literally hundreds of columns (Yes, I do mean literally)
  • Create primary keys
  • Create relationships with referential integrity through foreign keys
By Richard Waddell on 12/3/2011 8:22 AM
 

Many-to-Many Relationships A typical validation task that involves a many-to-many relationship involves a User who can update a number of Entities and an Entity that can be updated by a number of Users. For instance a School Book Inventory system where the counts for books at a particular school can only be updated by an employee of that school. Each employee can update a number of counts and each count can be updated by a number of employees. The application must prevent unauthorized data base updates and prevent employees from seeing counts from other schools.

We’ll start with validation. Although this article touches on validation on both client and server, to really understand what’s going on I suggest you see this post by Prem Ramanathan and this article he wrote for Code magazine....
By Richard Waddell on 6/14/2011 10:17 AM
The default Add and Edit screens generated by LightSwitch often don’t allow the control you need to meet the business requirements.  Consider the scenario where an entity must have a password column.  Ideally we’d want the ‘Add’ screen to look something like this:

image

The default Add and Edit screens are inadequate for two reasons.

No masked password text box A second password text box is required for matching, requiring a property that doesn’t...
By Richard Waddell on 5/21/2011 8:29 AM
 

image

LightSwitch removes so much tedium from programming that I’m hoping it can be integrated into any Silverlight application. Obviously that requires Custom Controls, so the focus becomes finding the best patterns for interaction between LightSwitch and Custom Controls.

My first goal was to incorporate drag and drop. I spent a lot of time trying to come up with scenarios that were not trivial but also wouldn’t take a long time to set up. But I kept running into a fuzzy area when I tried to think about...
By Richard Waddell on 5/5/2011 5:40 PM
Often we don’t care who the logged-in User is because we can control what they can do through Roles and Permissions. But if the User is a member of some group, it would be handy to place the Users table in a many-to-one relationship with that group. In this example the groups are SalesTeams made up of SalesPersons. All Sales made by a particular team are accessible only by members of that team.

To make that happen a new User is created, if necessary, when a SalesPerson is created. Since a SalesPerson is in a many-to-one relationship with SalesTeam, so is the User. This article shows you how to create the UserRegistration and then two ways to identify the SalesPerson associated with the logged-in User and thereby the relationship with SalesTeam and Sales.

Start by adding a SalesTeam entity:

image

...
Microsoft Visual Studio is a registered trademark of Microsoft Corporation / LightSwitch is a registered trademark of Microsoft Corporation