Alessandro Del Sole's Blog

/* A programming space about Microsoft® .NET® */
posts - 143, comments - 0, trackbacks - 0

My Links

News

Your host

This is me! This space is about Microsoft® .NET® and Microsoft® Visual Basic development. Enjoy! :-)

These postings are provided 'AS IS' for entertainment purposes only with absolutely no warranty expressed or implied and confer no rights.

Microsoft MVP

My MVP Profile

I'm a VB!

Watch my interview in Seattle

My new book on VB 2012

Order my book about VB 2012 on Amazon My book "Visual Basic 2012 Unleashed" is available. Click the cover!

My new book on LightSwitch!

Visual Studio LightSwitch Unleashed My book "Visual Studio LightSwitch Unleashed" is available. Click the cover!

Your visits

campusMVP.NET - Tutored online training for Microsoft developers

Follow me on Twitter!

Messenger me!


CyberInstaller Beta Tester

Download CIS 2008!!

CodePlex download Download my open-source projects from CodePlex!

Search the blog



Article Categories

Archives

Post Categories

.NET Framework

Blogroll

Help Authoring

Microsoft & MSDN

Setup & Deployment

Visual Basic 2005/2008/2010

LightSwitch: reading threads from StackOverflow with OData

As you might know, one of the most important new features in the next version of Visual Studio LightSwitch, currently in beta, is the support for OData.

You can read some post from Beth Massi about this topic, today I'm just showing a different usage.

OData is an open protocol based on WCF Data Services and allows managing data sets through services. If you visit the Ecosystem page of the OData portal, you can find a list of public services from 3rd party producers, including the well-known StackOverflow web site, which offers a very popular forum platform.

Imagine you want to read your favorite threads from StackOverflow inside a LightSwitch application. After creating the project, the first thing you want to do is connecting to an external data source such as OData:

In the next screen of the Wizard we specify the service URL and credentials if required. In this case no credentials are required and Anonymous auth is enough:

In order to be sure that the connection works, click Test Connection and select the entity that will be used for the test:

By clicking Test you will be able to check that everything works. The next step allows selecting entities you want to import into the application. We are talking about entities, this means that LightSwitch is able of representing OData information as the classic entity. So, working with OData is exactly like with any other data source, including business logic, validation, queries, and so on. Let's select posts, tags, and comments:

When you click su Finish, LightSwitch will tell you that it needs to import the User entity as well, since this has a relationship with the Comment one. This demonstrates that LightSwitch perfectly knows how to handle this kinds of situations. Once imported entities and relationships, these will appear in the Table Designer the usual way:

You can replace Date Time with Date to optimize visualization and you can change the summary property from Body to Title. Now imagine you only want to show posts talking about LightSwitch. You can simply create a Query the usual way; Right-click the Posts table in Solution Explorer, then Add Query. The new query is called LightSwitchPosts and we are going to set a couple of filters like in the following figure (tags are lower case):

Now you can simply add a Search Screen pointing to the query:

If you have changed the Summary Property to be Title, in the Properties window you can set this to be Show as Link. I am using here the Cosmopolitan shell which has been released recently. This is how the application will appear when running:

As you can see we have retrieved the list of posts talking about LightSwitch in StackOverflow's forums. You can simply click the hyperlink to show the post details:

OData in LightSwitch opens to infinite new development scenarios, making your applications even more powerful.

Alessandro

Print | posted on martedì 27 marzo 2012 01:22 | Filed Under [ Visual Studio LightSwitch ]

Feedback

No comments posted yet.

Post Comment

Title  
Name  
Email
Url
Comment   
Please add 8 and 6 and type the answer here:

Powered by:
Powered By Subtext Powered By ASP.NET