Is it possible to generate partial class that implement IDataErrorInfo ValidateProperty method

Thread is closed for posting
3 posts, 0 answers
  1. Craig
    Craig avatar
    113 posts
    Member since:
    Nov 2011

    Posted 14 Feb 2014 Link to this post

    I'm just getting to grips with IDataErrorInfo and the partial classes required to implement the ValidateProperty methods.

    I did a simple example and have the error highlighted to the user in the UI ok.

    In my ValidateProperty method I have the code waiting for a match between a 'magic' string and the class's propertyname to check the length is within range.
    This is ok for a small number of columns but for many columns across many tables this will become painful both to create and maintain.  

    Perhaps I have missed something. Can Data Access generate these methods for me? 

  2. Craig
    Craig avatar
    113 posts
    Member since:
    Nov 2011

    Posted 19 Feb 2014 Link to this post

    Perhaps I can customise the code generation templates to do this for me. I'll look into this further. 
    Could you recommend where I should insert my extra partial class generation logic?
  3. Boris Georgiev
    Boris Georgiev avatar
    190 posts

    Posted 19 Feb 2014 Link to this post

    Hello Craig,

    The idea of the partial method ValidateProperty is that you should write your own partial class and implement the method there, so when the code generation of the domain model is launched, the partial classes will stay untouched. Otherwise the partial classes will be overwritten with the default ones.

    If you still want to customize the code generation templates, you can refer to this article. The ValidateProperty
    method can be found in the ClassGenerator.ttinclude file. 

    If any other questions arise or if you need any assistance with customizing the code generation templates do not hesitate to contact us again.

    Boris Georgiev
    OpenAccess ORM is now Telerik Data Access. For more information on the new names, please, check out the Telerik Product Map.
Back to Top