Best way to extend generated classes

3 posts, 1 answers
  1. Neil Mercer
    Neil Mercer avatar
    18 posts
    Member since:
    Sep 2009

    Posted 03 May 2010 Link to this post

    Hi,

    I have a simple database that I have created Entity Diagrams for and am accessing data fine.  On one of the tables I would like to add a derived column that won't be persisted to the database. 

    As one option I have a SQL view that reveals the original table plus the additional column.
    In a previous version of this project (using OA 2009) I had extended the generated class to include a new column and do the necessary query to determine its value.

    What is the recommended approach for QA 2010?  Ideally, does anyone have an example of the best way to extend the generated classes?

    Thanks,
    Neil.
  2. Answer
    Damyan Bogoev
    Admin
    Damyan Bogoev avatar
    581 posts

    Posted 06 May 2010 Link to this post

    Hi Neil Mercer,

    You could do the following steps in order to achieve this goal:
    1. Mark the class where the new property should be in as a partial;
    2. Add a new class file which will contain section from the class. Here you could add the new property;
    Using this approach in case of regenerating the class the changes will be saved in the new class file.
    Hope that helps.

    Greetings,
    Damyan Bogoev
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  3. DevCraft banner
  4. Neil Mercer
    Neil Mercer avatar
    18 posts
    Member since:
    Sep 2009

    Posted 06 May 2010 Link to this post

    Hi Damyan.

    That's what I ended up deciding on, so thanks for confirming it's the right approach.  So far it's working very well.

    Cheers,
    Neil.
Back to Top