This is a migrated thread and some comments may be shown as answers.

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

2 Answers 36 Views
Development (API, general questions)
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Craig
Top achievements
Rank 1
Craig asked on 14 Feb 2014, 04:35 PM
Hi
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? 

Regards
Craig

2 Answers, 1 is accepted

Sort by
0
Craig
Top achievements
Rank 1
answered on 19 Feb 2014, 09:58 AM
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?
Thanks
Craig
0
Boris Georgiev
Telerik team
answered on 19 Feb 2014, 03:02 PM
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.

Regards,
Boris Georgiev
Telerik
OpenAccess ORM is now Telerik Data Access. For more information on the new names, please, check out the Telerik Product Map.
Tags
Development (API, general questions)
Asked by
Craig
Top achievements
Rank 1
Answers by
Craig
Top achievements
Rank 1
Boris Georgiev
Telerik team
Share this question
or