Beth's Chinese blog
Check it out, I did a podcast with Ken Levy on Wednesday here on campus and he posted it yesterday evening. In this one I chat with him about the release of Visual Studio LightSwitch with the latest news and resources. Always a fun time chatting with Ken!
CodeCast Episode 109: Launch of Visual Studio LightSwitch 2011 with Beth Massi
Also check out these resources for more info on Visual Studio LightSwitch:
And get involved with the community:
Enjoy!
As Jason Zander and the LightSwitch Team just announced, we released Visual Studio LightSwitch today, whoohooo! It’s been a long, fun road to our final release and we are so excited to get this into your hands today! I am personally excited about this product and the community that is building around it. Congrats to the LightSwitch team and a special thanks to the entire community for their support! I will continue to do my best helping the community and providing technical learning content so tune into my blog here as well as the newly updated Dev Center, your one-stop-shop for everything LightSwitch:
Visit the LightSwitch Developer Center http://msdn.com/lightswitch
Visual Studio LightSwitch is the newest edition of the Visual Studio family and is the simplest way to build business applications for the desktop and the cloud. For the end-user developer this means you can quickly create professional quality business applications with minimal code. For the professional developer you can customize LightSwitch with your own code, controls and even build extensions that can add more capabilities than what you get out of the box. Check out the resources below for more information.
MSDN Subscribers can install LightSwitch from the subscription site. Everyone else can download the trial version here and on Thursday you will be able to purchase LightSwitch. Please see the installation notes on the LightSwitch Team blog and the official readme.
Check out these learning resources, samples and starter kits to kick start your LightSwitch application development.
Get an Overview of LightSwitch
Watch the instructional LightSwitch "How Do I?" videos
Learn how to build LightSwitch Applications
Download Starter Kits
Download Code Samples
Interact with the LightSwitch Community on our forums, blogs and social sites.
Ask Questions in the Forums
Read the official LightSwitch Team Blog
Become a LightSwitch Fan and
Visual Studio LightSwitch is the simplest way to create professional quality, data-centric, business applications that can be deployed to the desktop or the cloud. Today MVP Kunal Chowdhury released an E-Book for the beginner wanting to get started building LightSwitch applications.
E-Book: Beginners Guide to Visual Studio LightSwitch
Kunal is another one of our LightSwitch community rock stars and is a huge contributor to the SilverlightShow.net website, a community portal dedicated to Microsoft Silverlight and Windows Phone 7 technologies. Thank you Kunal for bringing LightSwitch training and tutorials to this site!
http://www.silverlightshow.net/Learn/LightSwitch.aspx
And as always, you can find more from the LightSwitch Team here:
Visual Studio LightSwitch provides a rich extensibility model for the professional developer looking to customize LightSwitch beyond what you get out of the box. One of these extensibility points is the creation of custom UI controls. Yesterday MVP Michael Washington released an E-Book for the professional developer looking to extend LightSwitch with custom Silverlight controls. It will walk you through creating LightSwitch custom controls even if you are a total beginner and have not created a Silverlight control before.
E-Book: Creating Visual Studio LightSwitch Custom Controls (Beginner to Intermediate)
Michael is one of our LightSwitch community rock stars and has a whole site dedicated to helping people get the most out of LightSwitch business application development. I encourage you to check out his site and get involved:
LightSwitchHelpWebsite.com
Thanks for all you do!
In my last article I showed how to connect LightSwitch to SharePoint data in order to pull users’ Task Lists into your LightSwitch applications. If you missed it:
Using SharePoint Data in your LightSwitch Applications
There we created a screen that pulled up the logged in users’ tasks from SharePoint so they could modify them directly. We created a new screen to do this which presented just the data from SharePoint. In this post I want to show you how you can relate SharePoint data to data stored in the database and then present that on a single screen. There are a couple lines of code you need to write when you want to edit data from multiple data sources regardless if that data is coming from SharePoint or another data source like an external database. For a video demonstration of this technique please see: How Do I: Save Data from Multiple Data Sources on the Same Screen?
One of the most compelling features in LightSwitch is its ability to relate entities (tables or lists) across disparate data sources. For instance you could have a product catalog database which only stores product details and relate that to another table in a completely separate order management database. Or you could relate a list of issues stored in SharePoint to a customer table in a database. In this example I’m going to do just that, I want to display Customer Issues stored in SharePoint on the same screen as my Customer details stored in my database.
So I’ve set up a list called Customer Issues based on the Issues template in SharePoint. I’ve modified the list to also include an additional required text field called Customer ID.
We’ll use this to relate the Customer record in our database. For this example, we’ll auto-generate the CustomerID in LightSwitch to be a GUID (global unique identifier) but you could choose to use any field shared across the data sources. So I’ve created a Customer table in my LightSwitch application with the following properties:
Notice in the properties window that I’ve also set the CustomerID property to be included in the Unique Index and unchecked Display by Default since we are going to auto generate this value. Drop down the Write Code button at the top of the designer and select the Customer_Created method and write this code:
Private Sub Customer_Created() Me.CustomerID = Guid.NewGuid.ToString End Sub
Next we need to connect to SharePoint and relate our CustomerIssue list to the Customer. As I showed in the last post you can connect to SharePoint by right-clicking on the Data Sources node in the Solution Explorer (or click the “Attach to External Data Source” button at the top of the Data Designer), then select SharePoint as the data source type. Click Next and specify your SharePoint site address. LightSwitch will present all the Lists defined in the site. I’ll select CustomerIssues and that will automatically pull in the UserInformationList since this is related to CustomerIssues.
Click Finish and this will display the CustomerIssue entity in the Data Designer. Next we need to set up the relation to our Customer table. Click the “Relationship” button at the top of the designer and in the To column select Customer. Then you will need to select the Foreign and Primary keys below. This is the CustomerID field we added which is the “Primary” or unique key on the Customer.
Notice that a dotted line is drawn between related entities across data sources. This means that LightSwitch cannot enforce the referential integrity of the data but it can relate the data together. In other words, we cannot prohibit the deletion of a Customer if there are still Issues in SharePoint but we can relate the data together if it exists.
Creating a screen that displays data across multiple data sources is a no brainer – it’s the same steps you would use for any other data in the system. Click the “Screen” button at the top of the Data Designer or right-click on the Screens node in the Solution Explorer to add a new screen. For this example I’ll use the List and Details Screen. Select the Customer as the screen data and include the CustomerIssues.
At this point let’s hit F5 to build and run the application and see what we get so far. Create some new customers in the system. Notice however that the CustomerIssues grid is read only. At this point we can’t edit any of the SharePoint data, notice how all the Add, Edit, Delete buttons are disabled.
Why is this happening? The reason is because LightSwitch needs some more information from us in order to save the data properly. Specifically, it needs to know the order in which to save the data. LightSwitch can’t arbitrarily pick an order because in most systems the order is very important. In our case I want to make sure the Customer data is saved successfully before we attempt to save any issues to SharePoint.
What we need to do is write a couple lines of code. Close the application and go back to the CustomerListDetail screen we created. Drop down the Write Code button and select the CustomerListDetail_InitializeDataWorkspace and CustomerListDetail_Saving methods to create the stubs. In the InitializeDataWorkspace method you should notice a parameter saveChangesTo. This parameter is used to tell the screen to enable editing of the data, we just need to add the data sources we want to work with to the list. Then in the Saving method we need to specify the order in which we want to save the changes. To access the data sources you use the DataWorkspace object.
Public Class CustomersListDetail
Private Sub CustomersListDetail_InitializeDataWorkspace( saveChangesTo As System.Collections.Generic.List(Of Microsoft.LightSwitch.IDataService)) saveChangesTo.Add(Me.DataWorkspace.ApplicationData) saveChangesTo.Add(Me.DataWorkspace.Team_SiteData) End Sub Private Sub CustomersListDetail_Saving(ByRef handled As Boolean) Me.DataWorkspace.ApplicationData.SaveChanges() Me.DataWorkspace.Team_SiteData.SaveChanges() handled = True End Sub End Class
Now run the application again and this time you will be able to add, edit and delete Customer Issues and save them to SharePoint. And if you look in SharePoint you will see that LightSwitch automatically set the CustomerID for us as specified by the relationship.
By the way, this technique is not specific to SharePoint. You can relate data from other external data sources like databases as well and the same code would need to be added in order to support saving across them on a single screen. LightSwitch does almost all of the heavy lifting for us but it’s important in this case to be explicit about how our data is updated so that it ends up being saved correctly in any scenario.
The past couple weeks I’ve been recording more LightSwitch How Do I videos for the Developer Center in preparation for the Visual Studio LightSwitch release on July 26th! I’ve been announcing them on the LightSwitch Team blog but if you’ve missed them here’s a rollup of what I got out there so far. I’m doing more each week so check this page often:
Watch all the LightSwitch How Do I videos
Here are some of the latest ones I’ve done:
#13 - How Do I: Deploy a LightSwitch Application to Azure? #14 - How Do I: Modify the Navigation of Screens in a LightSwitch Application? #15 - How Do I: Open a Screen After Saving Another Screen in a LightSwitch Application? #16 - How Do I: Connect LightSwitch to an Existing Database? #17 - How Do I: Connect LightSwitch to SharePoint Data? #18 - How Do I: Save Data from Multiple Data Sources on the Same Screen?
I just completed two more that should release soon. I’m aiming to have 30 done by the 26th but I really want to take a couple days of vacation while the weather is so awesome here so we’ll see how many I get out there in time. Rest assured I’ll be creating these beyond launch and rolling out content every week on the Developer Center and we have a lot of site updates planned for the 26th so stay tuned!
Stay up to date by signing up for e-mail launch updates.