DSW and horizontal inheritance

6 posts, 0 answers
  1. Fredrik
    Fredrik avatar
    4 posts
    Member since:
    Oct 2012

    Posted 30 Jul 2013 Link to this post

    Hello,

    I'm working on creating a Web Service from my Openaccess ORM model.
    In my model I use horizontal inheritance from a Person class to a Client and Contact class. (The Person class is set to Abstract)
    In the generated Web Service, when I access the Clients, I can only see the Client properties and none of the Person properties.
    Is this a limitation in the Wizard or is there a way to include the Person properties in both Client and Contact?

    Thanks!
  2. Dimitar Tachev
    Admin
    Dimitar Tachev avatar
    67 posts

    Posted 01 Aug 2013 Link to this post

    Hi Fredrik,

     
    In general it is possible to include the Person properties in the Client and Contact ones but it is depending on the used service type.

    Could you please provide us with more details about the version of Telerik OpenAccess ORM that you have installed and the wizard that you are using? The DSW one is deprecated and it is replaced by the Add OpenAccess Service wizard. If you are already using the Add OpenAccess Service wizard, could you please specify the service type that you have chosen in its Select Service tab?

    I am looking forward to your feedback.

    Regards,
    Dimitar Tachev
    Telerik
    OpenAccess ORM Q2 2013 brings you a more powerful code generation and a unique Bulk Operations support with LINQ syntax. Check out the list of new functionality and improvements shipped with this release.
  3. DevCraft banner
  4. Fredrik
    Fredrik avatar
    4 posts
    Member since:
    Oct 2012

    Posted 01 Aug 2013 Link to this post

    Hi,

    Thanks for your reply! Yes, I am using the Add OpenAccess Service Wizard. I just tried with the most recent version available from your homepage and I get the same result. I generated a Service with the type: WCF Data Servce OData v3.

    Thanks!
  5. Dimitar Tachev
    Admin
    Dimitar Tachev avatar
    67 posts

    Posted 06 Aug 2013 Link to this post

    Hi Fredrik,

     
    Based on the details that you provided us I was able to reproduce this behavior.

    The reason for not getting the inherited properties is a limitation of OData 3. As described in their documentation at point (6.1.2) "An entity type that provides a value for the base type attribute MUST NOT declare a key with the edm:Key element" which means that you cannot have the horizontal inheritance working because in this type of inheritance the primary key properties are in the derived classes.

    Based on this article describing the new features of OData 4 which is not released yet and its point (1i): "We allow abstract entity types to be defined without keys; the first non-abstract derived type must specify a key if not already specified." I suppose that the imitation could be removed in a future version of the OData services. 

    Meanwhile as a workaround of this issue I suggest you modify the

    private ResourceProperty CreateResourceProperty(MetaMember member)
    method of the OpenAccessMetadataProvider which could be found in the Telerik.OpenAccess.Data folder and by default it is filtering the properties in the following way:
    if (member == null ||
        member.IsVisible ==
    false ||
        member.MemberAccessModifier !=
    MemberAccessModifier.Public)
    {
        return null;
    }

    If you remove the validation for the IsVisible setting of the members you will get the inherited properties directly from the derived classes metadata where we store them as invisible ones. For your convenience I also prepared a sample application demonstrating this approach - please find it attached.
     
    In general this setting is used for filtering only our internal properties like mapped Version columns and class ids in other inheritance strategies - e.g. using a vertical inheritance.

    Please bear in mind that this approach will work property only if you use a model with a horizontal inheritance without mapped version columns.

    I hope this is applicable for you. Do not hesitate to contact us back if you need any further assistance.


    Regards,
    Dimitar Tachev
    Telerik
    OpenAccess ORM Q2 2013 brings you a more powerful code generation and a unique Bulk Operations support with LINQ syntax. Check out the list of new functionality and improvements shipped with this release.
  6. Fredrik
    Fredrik avatar
    4 posts
    Member since:
    Oct 2012

    Posted 06 Aug 2013 Link to this post

    Hi again,

    Thanks for a very thorough explanation! I will try your workaround and get back to you!

    Regards!
  7. Fredrik
    Fredrik avatar
    4 posts
    Member since:
    Oct 2012

    Posted 06 Aug 2013 Link to this post

    Perfect! It works!!

    Thanks again!

    Regards!
Back to Top
DevCraft banner