locked
Client Error Validation RRS feed

  • Question

  • All the Microsoft-employed WPF architects I've heard, along with many non-Microsoft bloggers, are promoting MVVM as the way to design, test and build WPF clients.

    The basic implementation of this requires a following couple principles:  ui data updating is performed by INotifyPropertyChanged, validation is performed by IDataErrorInfo or a similar method.

    I can easily implement INotifyPropertyChanged through http://www.thejoyofcode.com/Making_webdatagen_data_binding_friendly.aspx .

    Implementing IDataErrorInfo is more problematic.  Obviously it didn't get into V1 (http://social.msdn.microsoft.com/Forums/en-US/adodotnetdataservices/thread/9f7fa4a8-c7bd-4f68-a88c-1edd82d70c86/) . 
    I can't just implement it using a partial class because the Error property gets passed back to the server, which then hiccups.  I don't see any way to turn off spurious properties (which would be a successful work-around).

    This approach seems close:
    but without restating every field, I'm not sure how I'd do the decorations.  Is there any relatively easy way to implement error checking?

    The more general question is, how have people actually built MVVM architected WPF clients using ADO.net Data Services?  Is it even possible?  I don't see any descriptions of implementations in the blogs or Microsoft documentation.   The microsoft WPF architects seem to have completely avoided EF and Astoria.

    Thanks,
    Peter
    Wednesday, February 11, 2009 10:37 PM

Answers

  • yes of course is possible marbles, from my last post on your mammoth parital class bll topic, i have implemented some helper classes, I cant copy and paste here as it is not my IP however i can write some thing similar. 

    You can still use idataerrorinfo, the error property and any other properties you want to use can be easily removed from the atom document before it is sent to the server and on this link you will see how to do it.

    http://blogs.msdn.com/phaniraj/archive/2008/12/11/customizing-serialization-of-entities-in-the-ado-net-data-services-client-library.aspx

    there you will learn how to tell the client framework to ignore properties so they are not sent to the client.

    And for wpf there is many ways to do validation you can use exceptions that are cough by the binding framework (if you use the validation on exceptions option on the Binding Markup extention) or using the idata error info inteface. there is loads of examples on how to implement some good frameworks around that, i suggest for you to look at the CSLA from lhotka : http://lhotka.net/cslanet/
    use that code as reference, also have a look at some community programs like Blog.Net, Das.Blog, there is a Ton of them with implementation off the idataerrorinfo really good ones too.

    There is very little official examples on msdn or on other sites. Mike Taulty, Phaniraj and hopefully my blog (when i get around publishing my draft from windows live writer) all have some good examples.

    Daniel Portella - http://undocnet.blogspot.com - This posting is provided "AS IS" with no warranties, and confers no rights. If this post is answered your question please mark as the answer and if it is helpful do like wise.
    Thursday, February 12, 2009 12:30 AM

All replies

  • yes of course is possible marbles, from my last post on your mammoth parital class bll topic, i have implemented some helper classes, I cant copy and paste here as it is not my IP however i can write some thing similar. 

    You can still use idataerrorinfo, the error property and any other properties you want to use can be easily removed from the atom document before it is sent to the server and on this link you will see how to do it.

    http://blogs.msdn.com/phaniraj/archive/2008/12/11/customizing-serialization-of-entities-in-the-ado-net-data-services-client-library.aspx

    there you will learn how to tell the client framework to ignore properties so they are not sent to the client.

    And for wpf there is many ways to do validation you can use exceptions that are cough by the binding framework (if you use the validation on exceptions option on the Binding Markup extention) or using the idata error info inteface. there is loads of examples on how to implement some good frameworks around that, i suggest for you to look at the CSLA from lhotka : http://lhotka.net/cslanet/
    use that code as reference, also have a look at some community programs like Blog.Net, Das.Blog, there is a Ton of them with implementation off the idataerrorinfo really good ones too.

    There is very little official examples on msdn or on other sites. Mike Taulty, Phaniraj and hopefully my blog (when i get around publishing my draft from windows live writer) all have some good examples.

    Daniel Portella - http://undocnet.blogspot.com - This posting is provided "AS IS" with no warranties, and confers no rights. If this post is answered your question please mark as the answer and if it is helpful do like wise.
    Thursday, February 12, 2009 12:30 AM
  • Hi Dan,

    Yea, I guess that other topic was the little posting that grew :).

    Thanks for the pointers.  I'll definitely chase them down.
    Wow.  Phani's exclusion method is pretty cool.

    When you get a chance to post your framework, I'd love to see how you're doing it.

    I guess I should have been clearer in noting that for all the guys who write about MVVM, I hadn't seen an end-to-end solution or a framework with MVVM and Astoria.  I should have looked at it from the perspective of the component parts and them assembled them myself.

    Peter

    Thursday, February 12, 2009 1:09 AM
  • Dont blame yourself, there was not a lot of info out there speacially from the community so none of us would have known until we had used it on a live project. heeh Yeah Phaniraj post wasnt much use for I had figured out before i found it but it is useful to post here as resource. being lazy really and not having the time to update my blog.

    As soon as i get some time free from work things i wil be making a load of post on my blog i will let you know then.

    Daniel Portella - http://undocnet.blogspot.com - This posting is provided "AS IS" with no warranties, and confers no rights. If this post is answered your question please mark as the answer and if it is helpful do like wise.
    Thursday, February 12, 2009 9:44 AM