Base class for specific table

Thread is closed for posting
2 posts, 1 answers
  1. Doron
    Doron avatar
    8 posts
    Member since:
    Apr 2013

    Posted 02 Jun 2013 Link to this post

    I have a project that contains server side code (C# + MS-SQL) that needs to serve several clients, inclucing HTML+JS client, and a C# client
    since i hate to write the same code twice - i want to serialize my data between the server and the client using json that can be read by all clients.

    but since i have a C# client - i want it use the same class declaration for the serialization and parsing. for that i want to generate a class library project
    reference it by the client project and the OpenAccess projects
    and configure OA that the specific tables should be mapped to objects derived from a specific object from that shared library project.

    My problem is - how do i make OA generate the proper inheritance in the code it generates? (doing it manually is not an option since others will update the same code file - and somone might forget.

    PS: Interfaces will work for me almost as good as classes - so such a solution is good as well
  2. Answer
    Alexander avatar
    727 posts

    Posted 05 Jun 2013 Link to this post

    Hello Doron,

    I am afraid that it will not be possible to use base classes from a shared assembly - it is required for OpenAccess that all persistent classes (and their base classes, if any) are placed in one assembly.

    As an alternative, I would suggest you to try using interfaces. You could make your persistent classes implement the interfaces without the risk of losing the changed by using partial classes. For each persistent type that should implement an interface, add in another file (not auto-generated) code similar to the following:
    namespace MyModelNamespace
        public partial class MyPersistentClass : MyInterface

    Just make sure the namespaces and class names match the names of your persistent classes.

    OpenAccess Samples Kit boasts 50+ sample applications providing diverse real-life business solutions. Click to read more and see OpenAccess ORM in action.
Back to Top