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

Base Class

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.
Brian Levin
Top achievements
Rank 2
Brian Levin asked on 09 Jan 2012, 02:35 AM
Hi, I am experimenting with the OpenAccess ORM for my new Web application. I have been following the Sofia Car Rental example in the SDK and I have a pretty good idea how to do most things..... That said, I have an existing database with a lot of tables. Like most databases, most tables have an ID column and a Name column. What I'd like to do is create a base class that all generated classes should inherit from that have an Id and a Name (among other things) specified. My question is what is the best practice for using base classes for my automatically generated domain objects? I understand that if I modify the generated classes and later do an "update from database", that my changes will be overwritten. Anyway any guidance In the right direction would be most appreciated. Thanks in advance!

2 Answers, 1 is accepted

Sort by
0
Brian Levin
Top achievements
Rank 2
answered on 09 Jan 2012, 05:23 AM
In doing some further research and checking out the MvcForum example on the OpenAccess SDK I see that I really have a lot more control over how the domain objects are created using the Fluent Mapping API.   Am I correct in this line of thinking or is there another approach I should take?
0
Ivailo
Telerik team
answered on 11 Jan 2012, 06:34 PM
Hello Brian,

Addressing your first question about the base class, the best solution for you considering that you want all the classes to inherit from one and the same best class is to modify the code generation templates to automatically include the inheritance. We have a code library sample demonstrating this approach.

As an alternative, you can create a base class in the Visual Designer, but this is mostly applicable for scenarios where just a few classes will inherit from it.

To answer your question about Fluent API - it does offer more flexibility in your implementation and if you feel the Visual Designer approach with an auto-generated domain context is too constraining for your scenario, this is the API that can help you build your application exactly the way you want. The disadvantage is that you will have to code your entire mapping manually in a declarative manner.

For more information, check out the documentation articles and videos for the Code-Only approach.

Do not hesitate to contact us if you need any clarifications.

All the best,
Ivailo
the Telerik team

SP1 for Q3’11 of Telerik OpenAccess ORM is available for download

Tags
Getting Started
Asked by
Brian Levin
Top achievements
Rank 2
Answers by
Brian Levin
Top achievements
Rank 2
Ivailo
Telerik team
Share this question
or