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

DSW and horizontal inheritance

5 Answers 57 Views
Web Services
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Fredrik
Top achievements
Rank 1
Fredrik asked on 30 Jul 2013, 10:08 AM
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!

5 Answers, 1 is accepted

Sort by
0
Dimitar Tachev
Telerik team
answered on 01 Aug 2013, 04:29 PM
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.
0
Fredrik
Top achievements
Rank 1
answered on 01 Aug 2013, 04:46 PM
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!
0
Dimitar Tachev
Telerik team
answered on 06 Aug 2013, 10:19 AM
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.
0
Fredrik
Top achievements
Rank 1
answered on 06 Aug 2013, 11:06 AM
Hi again,

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

Regards!
0
Fredrik
Top achievements
Rank 1
answered on 06 Aug 2013, 11:17 AM
Perfect! It works!!

Thanks again!

Regards!
Tags
Web Services
Asked by
Fredrik
Top achievements
Rank 1
Answers by
Dimitar Tachev
Telerik team
Fredrik
Top achievements
Rank 1
Share this question
or