Quantcast
Channel: Frans Senden Blog » franssenden
Viewing all articles
Browse latest Browse all 10

Create Lightswitch App without any coding. Part I

$
0
0

In this tutorial I will show you how to create a simple application with Microsoft Lightswitch. The purpose of this little tutor is to demonstrate how to create a simple app without writing any code at all, since that is what a business-analyst or DIY-webapp creator wants to do in the first place. 

My first intention is to demonstrate this a (web) application in a browser on any html5 capable device. Perhaps in subsequent parts, I will show how to build a hybrid app.

Prerequisites: Visual Studio 2013.

We’re going to make a simple moviedb (imdb like… well ehm.. parts of it) app. The user will be able to manage his/her favorite movies including persons (like actors) and genres.

0. Start Visual Studio.

1. Choose File/ New Project / Lightswitch/ Lightswitch HTML Application. call it anything you like (MyMovieApp will do)

You’ll end up with a solution like this:

solution

2. Now we’re going to create our model. Right-click “Data Sources” in the MovieApp.Server-Project and select “Add Table”. Name this table “Movie” by typing just in place of “Table1Item”. Add following properties by just typing or selecting:

movieTable1

Next, make sure the row of “EditorsOpinion” is selected and in the propertieswindow click on “Choice List…” :

choiceList

And fill:

choiceList2

or any of your choice ;-)

3. For persons to appear or work in our movies, we’ll have to define another table: Create another table as described earlier and mirror following: (* Notify, when you ready typing “Person”, the table created under “Data Sources / ApplicationData” is called “People”, which is the automatic pluralization done for you by LS)

Person

4. Every movie has a “genre” -category. Thus, we create another table “Genre” with only 1 property “Name” of type String:

tableGenre

5. Now we have to create some association between movie and person. That is, a movie a movie has 0 or more people and a person can be part of 0 or more movies. a Many-to-Many relationship.

Since LS does not support Many-to-Many relationships we have to come up with some other solution. Simply do it the old fashion way and

- create a cross table; “MoviePerson” !

Next click the add relationship button as shown:

relationshipButton

Then, add a many to one relation from MoviePerson to Movie:

AddRelationMoviePerson1

Ok, lets do the same for MoviePerson to Person:

Click add relationship again and select “Person” table in the “To” Column:

MoviePersonToPerson

You’ll end up with some model diagram like this:

MoviePersonModelDiagram

6. Repeat step 5, but instead for MoviePerson, also make associations between Movie and Genre. You will end up with a table MovieGenre and a diagram looking like this:

MovieGenreDiagram

One Final step we have to take here. For a MoviePerson it is important to know which part he or she is playing in the movie. And by “part” of course I mean not only an acting role, but this could also be camera-assist, director, catering etc. ;-)

7. Add a property “Part” to table MoviePerson, of type String. Make it “Required.

Well, this is our model so far. In Part II we will continue by building some screens on this model. Till next!

 



Viewing all articles
Browse latest Browse all 10

Trending Articles