Category Archives: LightSwitch

LightSwitch build – Database View Permissions Needed

While attempting the build process for a LightSwitch application using the Windows authentication, Visual Studio would hang indefinitely. The application would otherwise build fine when not using authentication and would deploy on an IIS server successfully.

It appears that the developer trying to build the application needs “View Permissions” to the database (not just selected tables either) so that LightSwitch is able to reverse engineer the database during the build process. This is possibly needed to create the correct permissions within the application, since security can be defined down to the smallest element or function with code.

Tell your DBA that its only you (the developer) who needs the view permissions for the build, and that there is no security or data risk.

Hope this helps someone, it took me long enough to find!


LightSwitch – Data Connection Properties

A quick note for finding the database connection properties for a LightSwitch application…

In Visual Studio, switch the solution explorer window to File View. Then navigate to Common –> Data –> ApplicationDefinition.lsml. Search for the “<DataService” tag and there you should find all the necessary database connection info.

In this case I am connecting to database DBHSY002_E and my AD account is used for authentication.

LS VS Database connection properties

LS VS Database connection properties

ALSO: The data connection string can be found in the Web.config file. This is listed under the ‘Server Generated’ folder, but you have to click the ‘Show all Files’ icon at the top of the Solution Explorer window. This is why I could not find it at first, so annoying!

Filtering AutoComplete Boxes

In this example I have a search screen listing all the streets in the database with 3 autocomplete boxes for filtering – Continent, Country and City. When the user selects Continent, only those countries and cities within the continent should be listed in the auto complete box. Same for when a country is select, only cities within that country should be available within the city autocomplete box. Focusing just on the filter boxes, here is the quick version: Continue reading

Returning Records With Children

Here I have a screen for searching Street addresses.  Tables are Continent, Country, City and Street.

The database contains many Countries and Cities which do not have addresses. To make the user experience better I only want to load the autocomplete boxes with Countries and Cities that have addresses. Continue reading

Selecting Existing Child Records

This is something that wasnt so obvious to me at first. I wanted to associate existing street records with an asset record and managed to do so easily using a Modal Window Picker control. For a given asset I could select a street from the database and associate it, making it a child record. But I couldn’t do this when wanted to associate a country with a continent.

I also noticed that drop-down lists are provided for parent objects, but I cant reverse it so that parent objects can look up child objects. Continue reading

Globals In LightSwitch

I looked around the ‘net for how/where to create global variables in LightSwitch and one post showed how to do it for VB. For the life of me I couldn’t figure out how to do this in C#, so I decided to do it this way which I probably better anyway. It keeps more separation between native LightSwitch generated code and my own, which is probably what LS designers intended. Continue reading

Hyperlinks in LightSwitch

It looks like there is no native way of presenting a URL string as a clickable link. Fortunately there is an extension that caters for this: Pixata custom controls – the Web Link control. Continue reading