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

Is it possible to use inheritance / generics for an identity class?

3 Answers 103 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Peter
Top achievements
Rank 1
Peter asked on 23 Nov 2009, 06:10 PM
Hi

We're implementing a persistent audit trail which has an audit (log) table alongside each domain (business) table; each audit table has 3 columns:
 - EntityID - the primary key of the domain entity instance being logged
 - LockVersion - the optimistic locking version number of the domain entity instance at the time the audit record was created
 - ChangeSetID - foreign key referencing the 'change set' (roughly transaction) that changed the instance.

The EntityID and LockVersion fields together are the multi-field identity for the audit object, so we need to implement an application identity class.  As we will have hundreds of such classes, I wanted to implement it using a generic type, roughly:
    public abstract class AuditObjectID<EntityType> : IObjectId where EntityType : DomainEntity {
        ...
    }

but VEnhance didn't like that.

Further experiments indicate that the identity class can't use straightforward inheritance - defining the fields and required methods in a base class causes VEnhance to produce some odd errors (I can reproduce and supply the actual errors if useful, sorry I didn't keep them when I was doing the experiment).

Is this something that should work or is there a restriction that application entity classes have to be simple?
[We can live with that - we're generating this code anyway - but would prefer the more compact approach of a base class]

Best regards
Peter

3 Answers, 1 is accepted

Sort by
0
Accepted
PetarP
Telerik team
answered on 26 Nov 2009, 05:33 PM
Hi Peter,

Unfortunately we do not support inheritance for the identity class and I am not able to provide you with any workaround for achieving your goal. We are sorry for the inconvenience this might be causing.

Best wishes,
Petar
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Peter
Top achievements
Rank 1
answered on 30 Nov 2009, 08:47 AM
Thank you, Petar

We're generating this code, so I'll carry on with generating many identity classes (with the implementation delegated to a helper) - just didn't want to do that if there was a neat way to do it with inheritance / generics

Could you please put this on the list for consideration in a future release (even with generated code, having multiple classes is an overhead).
Regards, Peter
0
PetarP
Telerik team
answered on 03 Dec 2009, 07:06 AM
Hi Peter,

We will certainly consider the possibility of adding such functionality in the future. Thank you for your suggestion.

Greetings,
Petar
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
General Discussions
Asked by
Peter
Top achievements
Rank 1
Answers by
PetarP
Telerik team
Peter
Top achievements
Rank 1
Share this question
or