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

Base class for specific table

1 Answer 34 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.
Doron
Top achievements
Rank 1
Doron asked on 02 Jun 2013, 10:08 AM
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

1 Answer, 1 is accepted

Sort by
0
Accepted
Alexander
Telerik team
answered on 05 Jun 2013, 04:18 PM
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.

Regards,
Alexander
Telerik
OpenAccess Samples Kit boasts 50+ sample applications providing diverse real-life business solutions. Click to read more and see OpenAccess ORM in action.
Tags
Getting Started
Asked by
Doron
Top achievements
Rank 1
Answers by
Alexander
Telerik team
Share this question
or