Minggu, 23 Januari 2011

Link Round up on .NET RIA Services (April 13th)


A few more great posts on .NET RIA Services over the last week..

Again, let me know if I missed any…

Managed Extensibility Framework Preview 5 Released


A few days ago we released MEF Preview 5 on codeplex with all the source code, docs, test and samples you need to get started. While MEF will be a core part of .NET Framework 4, we are making these preview releases available so folks can use MEF today on top of .NET Framework 3.5.

I have been very happy with the feedback we have gotten so far on MEF and I hope you see that we are reacting to it.

Glenn has the best list of changes and enhancements, but Wes has some good tips on moving to Preview 5 as well!

Enjoy!

ScottGu Mix Keynote coding demo posted


A ton of folks have asked us about getting the source code to Scott’s cool coding demo.


image


Watch the demo


download the completed example code


Note, there are a couple of prereqs:



  1. Sql Server 2008 to run it.. works great with the free Sql Express 2008

  2. .NET RIA Services March '09 Preview

  3. Silverlight 3 Beta

Enjoy!


Complete demo steps:


1. In Views/CustomersPage.xaml.cs, in OnNavigatedTo(), add the following:



var context = new CustomersDomainContext(); 
customersList.ItemsSource = context.Customers; 
context.LoadCustomers();

This code loads the data from the DomainService class on the server. Notice the data is loaded asynchronously, but no ugly, hard to debug async code is needed.


2. In CustomerDetailsPage.xaml.cs OnNavigatedTo, add this code:



this.DataContext = context; 
int customerID = int.Parse(NavigationContext.QueryString['CustomerID']); 
context.LoadCustomerOrders(customerID);


This code grabs the Customer id off the query string and loads it up.. effectively a detailsview.

3. F5 the app, click on one of the customers.
clip_image002
clip_image004


4. Then sign up for the SaveButton Click event (last line in the following XAML snippet):



<Button x:Name='SaveButton' 
Style='{StaticResource SaveButtonStyle}' 
Click='SaveButton_Click'/>

5. In the code-behind CustomerDetailsPage.xaml.cs, add the following code to the newly-created event handler:



private void SaveButton_Click(object sender, RoutedEventArgs e) 
{ 
    context.SubmitChanges(); 
}

Notice how simple it is to save all your pending changes back to the server. The client has kept up with what has changed and sends back a smart diff-gram.


6. Ctrl+F5 the app , go back to the details page, now try editing the phone number and see how it’s validated nicely. Note that this validation occurs both client-side and server-side.
clip_image006


7. Click one of the items in the DataGrid, show how the chart updates. Select something in another group in the DataGrid and show cool chart animation.


8. Click “Save” to save data in the DataForm back to the database.

.NET RIA Services May 2009 Preview


Today we posted a minor update to .NET RIA Services. This release is mainly focused on addressing bug fixes we have heard in the forums and delivering on a few key areas… There are a lot of other long lead work items that will fall into future releases.


Download it today from: http://code.msdn.microsoft.com/RIAServices


Here is a list of what is available in the May 2009 Preview:-



  1. Tons of bug fixes. Most of the bugs reported in the forum have been addressed.

  2. New Business application Template… This template adds login\create new user to the Silverlight Navigation Application template.

    image


    imageimage


  3. Authentication Sample

  4. XML Metadata provider Sample… We have heard very clearly that folks want an option to store validation metadata outside of custom attributes. This sample shows how to find metadata in an Xml file, but you could easily extend to find validation information from a database.

  5. Linq2Sql Domain Provider Sample.. Out of the box we support POCO (plain old CLR object), Linq2Sql and Entity Framework, but we know folks are actively looking into building support for nHibernate, Sharepoint, etc. This is a great sample that shows you the ends and outs of writing a provider. It is the actual product code we use for the Linq2Sql provider (plus a little clean up).

  6. Updated asp:DomainDataSource that works great with asp Dynamic Data

All the samples (March 2009 and May 2009) can be found at http://code.msdn.microsoft.com/RIAServices


We’d love to hear what you think and what you’d like to see in the next preview!

The DZone interviews Hamilton Verissimo on MEF


image The DZone has a nice interview with Hamilton on MEF.

Microsoft MEF Q&A with Hamilton Verissimo de Oliveira

Hamilton is one of our PMs here at Microsoft as well as the creator of the very popular Castle Project and he will tell you what the core value of MEF, tell you if MEF a DI container or not and get you versed in the MEF terminology.

Read and Enjoy!

.NET RIA Services at TechEd 2009


Scott Morrison just published his demo files for his talks at Teched.. He did some great work on to of the SuperHeros demo we did at Mix09.

Get all the Tech Ed 2009 Demo Files

image

.NET RIA Services: Get your metadata from anywhere!


While the feedback on .NET RIA Services has been great, many people have commented on the way we store metadata as custom attributes on “buddy” classes of entities.

For example, in my Mix demo to get automatic validation like this:

image

I had to provide metadata on my entity class on the server like this:

image  
 


This is very cool and I believe works just fine in a lot of scenarios. But sometimes you want to pull metadata from another source. For example from a database or from calling a web service or by looking in an external metadata file.


So with the .NET RIA Services May Preview we added a neat little sample that shows how to build your own metadata provider and a specific implementation that works with an external metadata file. I’d expect you can pick up this sample and pretty easily update it to pull the metadata from your database or any other data source whenever the client XAP file is built.


For example, this validation form…


image


Is driven from this xml.. Again, notice that this is just a sample, and you can define your own format.



<Metadata xmlns='http://schemas.microsoft.com/riaservices/metadata/2009'>
  <MetaType Type='DomainModel.Product'>
    <MetaProperty Name='ProductCode'>
      <MetaAttribute Type='Key'/>
      <MetaAttribute Type='Required'/>
      <MetaAttribute Type='CustomValidation'>
        <Argument Type='Type' Value='TestDomainValidator'/>
        <Argument Type='string' Value='ValidateProductCode'/>
      </MetaAttribute>
    </MetaProperty>
    <MetaProperty Name='Name'>
      <MetaAttribute Type='StringLength'>
        <Argument Type='int' Value='50'/>
        <Property Name='MinimumLength' Value='10'/>
      </MetaAttribute>
    </MetaProperty>
  </MetaType>
</Metadata>


Check out the full sample or just the doc file explaining it and see the many other great .NET RIA Services based samples.