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

Best way to extend generated classes

2 Answers 85 Views
Getting Started
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Neil Mercer
Top achievements
Rank 1
Neil Mercer asked on 04 May 2010, 03:02 AM
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 Answers, 1 is accepted

Sort by
0
Accepted
Damyan Bogoev
Telerik team
answered on 06 May 2010, 03:12 PM
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.
0
Neil Mercer
Top achievements
Rank 1
answered on 06 May 2010, 11:41 PM
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.
Tags
Getting Started
Asked by
Neil Mercer
Top achievements
Rank 1
Answers by
Damyan Bogoev
Telerik team
Neil Mercer
Top achievements
Rank 1
Share this question
or