Register for Cloud Computing Bootcamp: Free Technical Training on Developing for Windows Azure |
- Register for Cloud Computing Bootcamp: Free Technical Training on Developing for Windows Azure
- MSDN Webcast: Security Talk - Protecting Your Data from the Application to the Database
- xna gunfight at mix and sxsw
- Silverlight TV 13: MVVM Light Toolkit
- WCF Ria Services For Real
- WCF Ria Services For Real
- WCF Ria Services For Real
- MSDN Windows Developer Center Redesign
- Episode #6 - Julie Lermon on Learning The Entity Framework
- Did you miss the IIS7 FastCGI Update ?
- How to extend Bing Maps Silverlight with an elevation profile graph - Part 2
- Its a POC don’t worry about the data…
- Interview with SilverlightShow Eco Contest Community Vote Winner
- Interview with SilverlightShow Eco Contest Grand Prize Winner
- Silverlight Cream for March 10, 2010 - 2 -- #811
- The Microsoft Silverlight Analytics Framework at Mix
- Where to See Me At MIX10
- Articles and Lab Experiments vs. Blog Posts
- Articles and Lab Experiments vs. Blog Posts
- Article: How to Get Started in WPF or Silverlight
Register for Cloud Computing Bootcamp: Free Technical Training on Developing for Windows Azure Posted: 11 Mar 2010 02:10 PM PST This two-day workshop will help you prepare to deliver solutions on the Windows Azure Platform. We've worked to bring the region's best Azure experts together to teach you how to work in the cloud. Each day will be filled with training, discussion, reviewing real scenarios, and hands-on labs. It's more than just a training class, it's also an event-in-a box. If you don't see a class near you, then throw your own. | ||||
MSDN Webcast: Security Talk - Protecting Your Data from the Application to the Database Posted: 11 Mar 2010 02:10 PM PST Securing a database is a difficult task. Learn about areas that application developers and database administrators should consider to help increase data security. Hear about topics ranging from securing the network channel to using proper authentication to new authorization features introduced in Microsoft SQL Server 2005. | ||||
Posted: 11 Mar 2010 12:31 PM PST Were getting ready to head out to sxsw and mix . We will have a booth at mix, and will be at the Microsoft booth and party at SXSW, if your in town come…. by and say Hi. One thing we will have at both is a quick fun game some of us came up with for Cynergy...( read more )...(read more) | ||||
Silverlight TV 13: MVVM Light Toolkit Posted: 11 Mar 2010 10:28 AM PST The latest episode of Silverlight TV is now available on Channel 9 ! In this episode, Silverlight MVP Laurent Bugnion of IdentityMine appears on the show to discuss using MVVM with Silverlight. Laurent and John discuss their experiences with MVVM and...( read more )...(read more) | ||||
Posted: 11 Mar 2010 09:33 AM PST In my previous post I discussed creating the database and tables for the Silverlight HVP configuration data. All that was great, and worked just dandy until it was time to get the data from the database server to the application running on the client. "But," I thought, "How hard can it be?" I've done a few mini-tutorials… should be straight-forward… And it was… sorta. Getting GoingThe steps are pretty straight forward:
One of the strengths of WCF RIA Services is also one of its most confusing aspects: there are many good designs to accomplish the same thing. I'm a big believer in doing things in the most intuitive and obvious way and then looking to optimize or improve if and when it proves to be needed. In this case, I had chosen to simplify the persistence of the various fields in my business objects as simple types in the database. For example, here is the Topics class and its base class: namespace SilverlightHVP.ViewModel { public class Listable { public string TextToDisplay { get; set; } public ImageSource Image { get; set;} public int ID { get; set; } } public class Topic : Listable { public TimeSpan TopicOffset { get; set; } } }
Notice that Image is of type ImageSource and TopicOffset of type Timespan. Here is how they are declared in the database:
Each record has a unique ID, and Topic's MyListableID is a foreign key into Listable, linking the two into, effectively, a single object. It is an interesting aside that normalizing the Topics, Items and Links tables called for factoring out the same fields into a new table as were factored out into a base class when creating the types. In many ways this makes sense, as in both normalization and refactoring, the goal is to eliminate duplication. TopicsView SELECT Listables.ID AS ListablesID, Listables.TextToDisplay, Listables.ImageSource, Topics.ID AS TopicsID, Topics.Offset, Topics.MyItem, Topics.MyListableID FROM Listables INNER JOIN Topics ON dbo.Listables.ID = dbo.Topics.MyListableID
Returning to my original point, however, while the Listable type stores its Image field as an ImageSource, the ImageSource field in the database is a string. Similarly, while the Topic type stores the Offset as a TimeSpan, the value is stored in the database as an integer (the number of seconds). There are numerous ways to resolve these differences, among them:
If I were starting from scratch, and if I knew that the only way these values would ever be stored is in the database, I could make a good argument for the idea of storing the values in the database as the same types used in the objects. That is not how this evolved however, and, in fact, if/when we decide to persist the objects to Xaml before sending them to the db, any work that was done to create an isomorphic mapping to the database would be wasted. Thus, again, I let the design evolve organically, even if that doesn't leave me, from time to time, with what looks like the optimal (or at least text-book) way of doing things. Creating the Entity Data ModelThe mechanics of creating the Entity Data Model couldn't be much easier. Step 1 is to Add a New Item to the SilverlightHVP.Web project, of type ADO.NET Entity Data Model (found in the Data Templates). When you click Add, Visual Studio will ask for your source, in this case you will pick Database. It will then allow you to create a Connection String to the configuration database. Once the connection is established, you pick the tables and views you want in the Entity Data Model, and hey! Presto! Visual Studio creates the model for you. The relationships in the Entity Data Model map to the relationships in the database. You are free to modify the entities, but it is simpler to let Visual Studio do the heavy lifting. It is very important to build the SilverlightHVP.Web project at this point, before going further. With the project built, you just click on Add New Item to SilverlighHVP.Web once more, and this time click on the Web template, and then on Domain Service Class, and give your new service a name (e.g., HVPConfigRiaDomainService) This brings up the Add New Domain Service Class dialog, in which you pick the entities (from the Entity Data Model) you wish to access through your WCF Ria Service. Since I want access to them all, but do not need to edit them, I'll check all the Entities in the left column. Hiding, inconspicuously in the lower left corner is an important CheckBox: Generate associated class for metadata. Click that CheckBox and then click OK. Visual Studio will place you in the editor, inside the HVPConfigRiaDomainService.cs file. Here you will see the code that was generated to retrieve data from your tables. The generated code can be modified to select the records you want, and to order the results as well, as shown in the next code listing.
using System.Linq; using System.Web.DomainServices.Providers; using System.Web.Ria; namespace SilverlightHVP.Web { [EnableClientAccess()] public class HVPConfigRiaService : LinqToEntitiesDomainService<yzf265_hvp_User> { public IQueryable<Item> GetItems() { return this.ObjectContext.Items; } public IQueryable<ItemsView> GetItemsViews( int SetID ) { return this.ObjectContext.ItemsViews.Where( e => e.MySetID == SetID ); } public IQueryable<Link> GetLinks() { return this.ObjectContext.Links; } public IQueryable<LinksView> GetLinksViews( int itemID ) { return this.ObjectContext.LinksViews.Where( e => e.MyItem == itemID ).OrderBy( e => e.Offset ); } public IQueryable<Listable> GetListables() { return this.ObjectContext.Listables; } public IQueryable<Topic> GetTopics() { return this.ObjectContext.Topics; } public IQueryable<TopicsView> GetTopicsViews( int itemID ) { return this.ObjectContext.TopicsViews.Where( e => e.MyItem == itemID ).OrderBy( e => e.Offset ); } } } Retrieving Items, Topics and LinksWhen the program begins we create a situation identical to that of when the user clicks on a link: we need to retrieve a new Set of items. Remember that a Set consists of one or more Items (e.g., videos) and each Item has zero or more Topics and zero or more Links. Each topic is tied to an offset in a given video, each Link is tied to a Set. The State constructor takes an integer parameter indicating which Set to obtain (at the moment, the shell creates the State object and passes in the value 0). The constructor calls the GetNewState method, private HVPConfigRiaContext itemsContext; private void GetNewSet( int setID ) { if ( setID < 0 ) { System.Windows.MessageBox.Show( "That link is not yet implemented" ); return; } currentSet = new Set(); itemsContext = new HVPConfigRiaContext(); try { var LoadItems = itemsContext.Load( itemsContext.GetItemsViewsQuery(setID) ); LoadItems.Completed += new EventHandler( LoadItemsCompleted ); } catch { System.Windows.MessageBox.Show( "That link is not yet implemented" ); return; } } The heart of this method is within the try block, where we ask the Context object to load the GetItemsViewQuery we modified above. The object returned from a call to Load is of type LoadOperation<ItemsView> which we can use to set an event handler on the completion of the asynchronous Load. When the Load completes, we'll combine three activities into one:
private void LoadItemsCompleted( object sender, EventArgs e ) { var dbItems = itemsContext.ItemsViews; if ( dbItems.Count == 0 ) { System.Windows.MessageBox.Show( "Unable to retrieve items from the database." ); return; } ItemHolder holder = null; currentSet.ItemHolders = new ObservableCollection<ItemHolder>(); foreach ( var dbItem in dbItems ) { holder = new ItemHolder(); var item = new Item( dbItem.ListablesID ); item.TextToDisplay = dbItem.TextToDisplay; item.ItemUri = new Uri( dbItem.ItemUri.ToString() + "/manifest", UriKind.Absolute ); item.Image = new BitmapImage( new Uri( dbItem.ImageSource, UriKind.Absolute ) ); holder.theItem = item; currentSet.ItemHolders.Add( holder ); } this.CurrentItem = currentSet.ItemHolders[ currentItemHolderOffset ].theItem; OnStateChanged(); } The penultimate line of code shows the CurrentItem property of State being set within the Item object that is held by the ItemHOlder located at the currentItemHolderOffset offset. That value is set to 0 initially, and updated as the current item changes. Notice that the value is set by way of the property. The setter for the CurrentItem property does a bit of housekeeping, private Item currentItem = null; public Item CurrentItem { get { return currentItem; } set { currentItem = value; SetCurrentItemHolderOffset(); GetTopicsAndLinksForItem(currentItem.ID); OnCurrentItemChanged(); } } Specifically, the setter updates the CurrentItemHOlderOffset value and, even more important, calls the GetTopicsAndLinksForItem method, passing in the ItemID. The Items (and the links) are then independently and asynchronously loaded from the database, much as the Item was. Lazy LoadingThis design allows for the topics and links of an item to be loaded to the client only as need and asynchronously, providing a more responsive UI that is not bogged down waiting for any of the list boxes to fill. Since the video is streamed in small bursts whose quality (size) is set in response to current bandwidth, the entire application should appear "snappy" even though three queries are returning data for the configuration.
I'm very happy to report that we are on track for version 1 to be ready in time for Mix, and we are already selecting the most important new features for versions 1.1 and 2.0. For more information on this project, please take a look at the CodePlex site. This work is licensed under a Creative Commons license. | ||||
Posted: 11 Mar 2010 09:33 AM PST In my previous post I discussed creating the database and tables for the Silverlight HVP configuration data. All that was great, and worked just dandy until it was time to get the data from the database server to the application running on the client Read More......(read more) | ||||
Posted: 11 Mar 2010 09:33 AM PST In my previous post I discussed creating the database and tables for the Silverlight HVP configuration data. All that was great, and worked just dandy until it was time to get the data from the database server to the application running on the client...( read more )...(read more) | ||||
MSDN Windows Developer Center Redesign Posted: 11 Mar 2010 05:08 AM PST We've all been busy on our various sites. Earlier this year, we put out an overall redesign for MSDN. Yesterday, the asp.net site team went live with a redesign to the asp.net site (looks awesome, btw). Also yesterday, we went live with the redesigned...( read more )...(read more) | ||||
Episode #6 - Julie Lermon on Learning The Entity Framework Posted: 11 Mar 2010 10:17 AM PST Episode #6 - Julie Lermon on Learning The Entity Framework In this episode The Misfit Geek talks with Data Expert Julie Lerman on leanring LINQ to Entities and the Entity Framework. . Resources ...... Julie's Blog Geek Girl Dinners Julie's Book V2 Rough Cuts Julie's Book on Amazon If you are interested in advertising, have suggestions, or advice.... Please CLICK HERE and send them to me. Download Now ! Subscribe Via RSS ... Play Now ! ' /> Click to Play With Flash Read More......(read more) | ||||
Did you miss the IIS7 FastCGI Update ? Posted: 11 Mar 2010 08:41 AM PST In case you did, there are some interesting improvements like…. Monitor changes to a file . The module can be configured to listen for file change notifications on a specific file and when that file changes, the module will recycle FastCGI processes for the process pool. This feature can be used to recycle PHP processes when changes to php.ini file occur. To enable this feature use the monitorChangesTo setting in the <fastCgi> configuration element. Real-time tuning of MaxInstances setting . This MaxInstances setting dictates the maximum number of FastCGI processes which can be launched for each application pool. Set it to 0 to let FastCGI module automatically adjust the number of instances up or down based on the system load and number...(read more) | ||||
How to extend Bing Maps Silverlight with an elevation profile graph - Part 2 Posted: 10 Mar 2010 02:26 PM PST Introduction This is the second and conclusive article about an example of a Bing Maps extension using Silverlight. Let me briefly recall the objective: in the first article I wrote about the need which may arise when planning an itinerary, I underlined...( read more )...(read more) | ||||
Its a POC don’t worry about the data… Posted: 11 Mar 2010 05:37 AM PST Sorry to leave you hanging… In the last post we stopped at the question… But this is a POC ? Why would you do this, why would you not use static objects and have tight coupling and low cohesion surely this would be a faster route? Well its an interesting...( read more )...(read more) | ||||
Interview with SilverlightShow Eco Contest Community Vote Winner Posted: 11 Mar 2010 01:22 AM PST Next in our series of interviews with SilverlightShow Eco Contest winners is the Community Vote winner Cigdem Patlak . We talk about her expectations for MIX, sessions she would be most willing to attend, people she would like to meet there, and of course...( read more )...(read more) | ||||
Interview with SilverlightShow Eco Contest Grand Prize Winner Posted: 11 Mar 2010 12:49 AM PST The 3 winners in SilverlightShow Eco Contest are already getting packed for MIX10 in Vegas ! Before they fly away, we catch them to talk about their expectations for MIX, sessions they would be most willing to attend, people they would like to meet there...( read more )...(read more) | ||||
Silverlight Cream for March 10, 2010 - 2 -- #811 Posted: 10 Mar 2010 10:06 PM PST In this Issue: AfricanGeek , Phil Middlemiss , Damon Payne , David Anson , Jesse Liberty , Jeremy Likness , Jobi Joy ( -2- ), Fredrik Normén , Bobby Diaz , and Mike Taulty ( -2- ). Shoutouts: Shawn Wildermuth blogged that they posted My "What's New in...( read more )...(read more) | ||||
The Microsoft Silverlight Analytics Framework at Mix Posted: 10 Mar 2010 10:54 AM PST I'm excited to share with you that I'll be talking about a new framework for web analytics in Silverlight at our Mix conference in Las Vegas next week. Seven months ago I blogged about building a new analytics framework for Silverlight and now we...( read more )...(read more) | ||||
Posted: 10 Mar 2010 10:40 AM PST This weekend i am headed to Vegas for a week of designer/developer love. I plan to spend a lot of time in the phone sessions as well as in the Commons visiting with people. This year's MIX has be really excited about both Silverlight 4's continued maturation...( read more )...(read more) | ||||
Articles and Lab Experiments vs. Blog Posts Posted: 10 Mar 2010 09:59 AM PST ...( read more )...(read more) | ||||
Articles and Lab Experiments vs. Blog Posts Posted: 10 Mar 2010 09:59 AM PST ...( read more )...(read more) | ||||
Article: How to Get Started in WPF or Silverlight Posted: 10 Mar 2010 09:46 AM PST ...( read more )...(read more) |
You are subscribed to email updates from "microsoft" via ehsan in Google Reader To stop receiving these emails, you may unsubscribe now. | Email delivery powered by Google |
Google Inc., 20 West Kinzie, Chicago IL USA 60610 |
No comments:
Post a Comment