Base Class

3 posts, 0 answers
  1. Brian Levin
    Brian  Levin avatar
    11 posts
    Member since:
    Nov 2009

    Posted 08 Jan 2012 Link to this post

    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. Brian Levin
    Brian  Levin avatar
    11 posts
    Member since:
    Nov 2009

    Posted 08 Jan 2012 Link to this post

    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?
  3. DevCraft banner
  4. Ivailo
    Admin
    Ivailo avatar
    318 posts

    Posted 11 Jan 2012 Link to this post

    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

Back to Top