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

4 posts, 1 answers
  1. Peter
    Peter avatar
    23 posts
    Member since:
    Sep 2008

    Posted 23 Nov 2009 Link to this post

    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
  2. Answer
    PetarP
    Admin
    PetarP avatar
    754 posts

    Posted 26 Nov 2009 Link to this post

    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.
  3. DevCraft banner
  4. Peter
    Peter avatar
    23 posts
    Member since:
    Sep 2008

    Posted 30 Nov 2009 Link to this post

    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
  5. PetarP
    Admin
    PetarP avatar
    754 posts

    Posted 03 Dec 2009 Link to this post

    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.
Back to Top