Page 1 of 1

Omitting DataMember on reverse navigation properties

Posted: Thu 25 Apr 2013 06:54
by magnus
We have a change request for the DbContext template that may put us in the minority, but we would like to have the option of omitting the DataMember attribute on reverse navigation properties when using the WCF Data Contract option in the DbContext template, but we do want the attribute on regular properties, and of course on regular entity fields.

As an example, if there's an entity Order and another entity OrderLine, and OrderLine has a foreign key to Order, we want the Order property on the OrderLine entity to have DataMember, but the OrderLines property on the Order entity should not.

We have two reasons for this:
1. We're using the entity classes as DTO classes as well as in our internal code, and although we do use the navigation properties internally, we have no desire to expose the reverse navigation properties to anyone else.
2. We experienced some pretty severe issues when trying to import WSDLs using the data contract hierarchies with reverse navigation properties into SoapUI, presumably owing to the complexity of the hierarchy or possibly something to do with circular references. This may just be a bug with that program, but we can't be certain that the same problem won't affect other programs -- particularly other Java-based programs.

We've implemented this as a one-liner in our modified version of the DbContext template, although I'm sure that if you were to implement this it would have to be as a configurable option.

Re: Omitting DataMember on reverse navigation properties

Posted: Mon 29 Apr 2013 14:01
by Shalex
magnus wrote:we would like to have the option of omitting the DataMember attribute on reverse navigation properties
Thank you for your suggestion. We will investigate the possibility of implementing the corresponding option.

Could you please tell us your opinion concerning the many-to-many association because there is no way to distinguish reverse and direct properties for this type of association?

Re: Omitting DataMember on reverse navigation properties

Posted: Wed 08 May 2013 09:27
by magnus
Thanks for the reply. My personal feeling is that DataMember should be omitted on many-to-many associations since they are effectively relations that are "reverse on both sides".

By the way, this is how we implemented this in our little hack:

Code: Select all

if (WcfDataContractAttributes)
  if (relationProperty.Multiplicity != Multiplicity.Many)
    GenerateRelationWcfDataContractAttributes(relationProperty);
We added the second if-statement.

Re: Omitting DataMember on reverse navigation properties

Posted: Mon 27 May 2013 07:07
by Shalex
The "WCF DataMember Attribute on Navigation Properties" property is added to the DbContext and POCO templates for pointing the end (-s) where the attribute should be generated. We will post here when the corresponding build of Entity Developer is available for download.

Re: Omitting DataMember on reverse navigation properties

Posted: Thu 30 May 2013 14:24
by Shalex
New build of Entity Developer 5.5.115 is available for download now!
It can be downloaded from http://www.devart.com/entitydeveloper/download.html (trial version) or from Registered Users' Area (for users with active subscription only).
For more information, please refer to http://forums.devart.com/viewtopic.php?f=32&t=27232.