CSharpFeeds - All your C# feeds in one place.

Sponsors

Tuesday, May 26, 2009

.NET RIA Services: Get your metadata from anywhere!

by BradA via Brad Abrams on 5/26/2009 11:08:58 PM

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.

email it!bookmark it!digg it!

Original Post: .NET RIA Services: Get your metadata from anywhere!

Subscribe

New Feed

Product Spotlight

Recently Updated Sources

Legal Note

The content of the postings is owned by the respective author. CSharpFeeds is not responsible for the contents of the postings. This site is automatically generated and cannot be reviewed for abusive content. If you find abusive content on CSharpFeeds, please contact us. Designated trademarks and brands are the property of their respective owners. All rights reserved.

Advertise with us