Viewers: in countries Watching now:
Discover how to build professional apps that encompass the 17 major feature areas of Windows Phone, from XAML to multimedia to network access. In this course, author Michael Lehman details the standard hardware device configuration, teaches how to navigate the development environment, and explores the Windows Phone APIs. The course shows how to build sample applications while learning Windows Phone concepts and frameworks, including the Metro design language.
Surprise, surprise! Here we find ourselves in Visual Studio again. Let's update the data model now to have it access to database to do the querying to build our initial set of items and to implement the logic we need for the details page. So move over here is the Solution Explorer, open up the MainViewModel.cs, and put our new version in and see what we've changed. To start with, we have a local intense variable, we're going to hold the Sonnets dbDataContext.
And in our MainViewModel Constructor we're going ask the App class for the instances of the database that we've created there. Also as we did before, we're going to create art to ObservableCollection of ItemsViewModels for items and favorite items. All that remains the same. What's going to change now is the logic inside load data. So instead of looking at the data that we got from XML--which is what we did before--we're simply going to query the database for the Sonnets.
So the way you do queries using the SQL is to simply say var sonnetsInDB equals from sonnets, variable S, in dbDataContext.Item--remember that was the table we defined over layer in dbData Context. Select this and so that the equivalent of select star from Sonnets in the database. And now that we have that, we're going to create an observable collection of those sonnets in order to be able to iterate over them and create our ItemViewModel, and we'll simply then company properties from the Sonnet Objects into the ItemViewModel objects.
And then we added to the items list and again to the favorites list if it is a favorite sonnet, and that's all we need to do to love the data from the database. You can also see that add item to favorites and remove items from favorites are the same as what we use for the flat file version of Sonnets plus. But you might notice that the update database method is missing, and that's because we're going to use link to SQL over in the details page in order to do the actual updates. We don't need to do the updates here because we're not managing the XML file anymore.
So let's move on to updating the details page and fire this puppy up and see if it runs.
Find answers to the most frequently asked questions about Windows Phone SDK Essential Training .
Here are the FAQs that matched your search "" :
Sorry, there are no matches for your search "" —to search again, type in another word or phrase and click search.
Access exercise files from a button right under the course name.
Search within course videos and transcripts, and jump right to the results.
Remove icons showing you already watched videos if you want to start over.
Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.
Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.