Share via


.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="https://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.

Comments

  • Anonymous
    May 26, 2009
    PingBack from http://asp-net-hosting.simplynetdev.com/net-ria-services-get-your-metadata-from-anywhere/

  • Anonymous
    May 26, 2009
    I just heard about RIA Services and printed out the May documentation. RIA will be my summer project. Keep on inventing good stuff =)

  • Anonymous
    May 26, 2009
    While the feedback on .NET RIA Services has been great, many people have commented on the way we store

  • Anonymous
    May 27, 2009
    The comment has been removed

  • Anonymous
    May 27, 2009
    Thank you for submitting this cool story - Trackback from DotNetShoutout

  • Anonymous
    May 27, 2009
    If you are looking to follow this series, be sure to subscribe to my RSS feed at http://feeds.jasongaylord

  • Anonymous
    May 27, 2009
    If you are looking to follow this series, be sure to subscribe to my RSS feed at http://feeds.jasongaylord.com/JasonNGaylord

  • Anonymous
    May 27, 2009
    This issue was brought up at MIX, and it's cool to see that the comments from the industry were listened to. RIA DS will definetly be more flexible by integrating the metadata into the pipeline. Looking forward to the release, keep up the good work! :)

  • Anonymous
    May 28, 2009
    This seems like it could be really useful. I don't like my code cluttered with lots of meta data and it should be easier to change if it's in a database.

  • Anonymous
    May 30, 2009
    9efish.感谢你的文章 - Trackback from 9eFish

  • Anonymous
    May 31, 2009
    Looks like there is an issue with the XmlMetadataProvider. The metadata is not attached to properties that come from a base class. So in code like this (yes, I know its silly, but its to explain my point):    public partial class ProductBase    {        public string ModelNumber {get; set;}        public string Name { get; set; }        public int AvailableQuantity { get; set; }    }    public partial class Product : ProductBase    {        [Key]        public int ProductID { get; set; }        public string Description { get; set; }        public decimal UnitCost { get; set; }    } and my metadata XML file is: <Metadata xmlns="http://schemas.microsoft.com/riaservices/metadata/2009">  <MetaType Type="MyApp.DataModel.Product">    <MetaProperty Name="AvailableQuantity">      <MetaAttribute Type="Required"/>    </MetaProperty>    <MetaProperty Name="UnitCost">      <MetaAttribute Type="Exclude"/>    </MetaProperty>  </MetaType> </Metadata> Metadata is attached to properties of the product class (the UnitCost prop), but not to properties from the base class.

  • Anonymous
    June 02, 2009
    Great stuff. Steve Sanderson shows how to use DataAnnotations with his xVal library (on codeplex) for ASP.NET MVC. One thing I like about this library is that you can use a 'IRule' to create rules programmatically. So to the above question - I think it would be very cool to be able to load a set of validations based on some criteria and using a strategy pattern 'attach' a set of validation rules to a domain object. ie. the state of Ohio might have a different validation than the state of Kentucky - you could have your domain objects loosely coupled from the set of rules for each, loading them in to the domain object based on the state you are in and then apply those rules. To me this is just a matter of exposing the underlying rules interfaces - again, see xVal.  Maybe this provider here does this as well Great example though - I assume from above, you could keep different xml validation sets for different scenarios and load those dynamically as well.

  • Anonymous
    June 07, 2009
    I have previously written about the UNPLUGGED road trip that Mike , Nathan and I have been on. I also

  • Anonymous
    August 11, 2009
    出会ぃも今は逆援助!オンナがオトコを買う時代になりました。当サイトでは逆援希望のセレブ女性が男性を自由に選べるシステムを採用しています。経済的に成功を収めた女性ほど金銭面は豊かですが愛に飢えているのです。興味のある方はどうぞ

  • Anonymous
    August 12, 2009
    即ハメセレブは完全無料でご利用できる出会いコミュニティです。今までにない実績で、あなたの希望に合った人をお探しします。毎月考えられない豪華なイベントを開催しているので出会いを保障します

  • Anonymous
    August 13, 2009
    夏真っ盛り!女の子は開放的な気分で一人Hしたくてウズウズしてるっ!貴方は女の子のオ○ニーを見て気分を高めてあげてネ!もちろん、お手伝いしてもオッケーだよ!さぁ、今すぐ救援部にアクセスしよっ

  • Anonymous
    August 14, 2009
    プロフ見て興味ある方は連絡ください。基本的には携帯依存症なぐらい携帯いじるのとかメールするの好きなのでまずはメアドから交換しましょう。仲良くなったら電話もおっけーなんでよろしくo.natyu.natyu.o@docomo.ne.jp

  • Anonymous
    August 15, 2009
    大好評の逆ナンイベントが毎週開催決定!素敵な出会いのきっかけ探し・アイナビにきませんか?積極的な出会いを求める人達なら無料参加OK!あなたもほんの少しの勇気で素敵な彼氏・彼女をGETしちゃおう!

  • Anonymous
    August 16, 2009
    夏休みで家出する女の子が急増しています。最初はマンガ喫茶やネットカフェで過ごすことが多いようですが、すぐにお小遣いが無くなり家出掲示板で泊めてくれたり遊んでくれる男性を探す子が多いようです。当サイトはそんな女の子達をサポートしたいという人たちと困っている女性たちの為のサイトです

  • Anonymous
    August 17, 2009
    当サイトは、みんなの「玉の輿度」をチェックする性格診断のサイトです。ホントのあなたをズバリ分析しちゃいます!玉の輿度チェッカーの診断結果には、期待以上の意外な結果があるかも

  • Anonymous
    August 20, 2009
    毎月10万円を最低ラインとする謝礼を得て、セレブ女性に癒しを与える仕事があります。無料登録した後はメールアプローチを待つだけでもOK、あなたもセレブラブで欲求を満たしあう関係を作ってみませんか

  • Anonymous
    August 21, 2009
    よーやくプロフ持ちになれました。私の事気になった方がいましたら気軽にメールください。恋バナとか好きなんでよろしくでぇす。zuttozuttoissyodayo@docomo.ne.jp

  • Anonymous
    August 22, 2009
    女性会員様増加につき、当サイトの出張ホストが不足中です。女性の自宅やホテルに出向き、欲望を満たすお手伝いをしてくれる男性アルバイトをただいま募集していますので、興味のある方はTOPページから無料登録をお願いいたします

  • Anonymous
    August 23, 2009
    最近様々なメディアで紹介されている家出掲示板では、全国各地のネットカフェ等を泊り歩いている家出少女のメッセージが多数書き込みされています。彼女たちはお金がないので掲示板で知り合った男性とすぐに遊びに行くようです。あなたも書き込みに返事を返してみませんか

  • Anonymous
    August 24, 2009
    あなたのモテ度数を診断できる、モテる度チェッカー!日頃モテモテでリア充のあなたもそうでないヒキニートの貴方も隠されたモテスキルを測定して今以上にモッテモテになること間違いなし