web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Dynamics 365 Community / Forums / Finance forum / Extending contract cla...
Finance forum
Unanswered

Extending contract classes best practices

(0) ShareShare
ReportReport
Posted on by 252
Hi,

If let's say we created a custom service, where one of the inputs to the service is postal address

[DataContractAttribute]
class PostalAddressContract
{
    Description                                     locationName;
    LogisticsAddressStreet                   street;
    LogisticsAddressCityName             city;
    LogisticsAddressCountyId              county;
    LogisticsAddressStateId                  state;
    LogisticsAddressCountryRegionId  countryRegionId;
    LogisticsAddressZipCodeId            postCode;
}
 
And there was another service that needs to create postal addresses, but needs more fields in the postal address. Is it better to create a new contract for this service that extends the first contract and use it?

[DataContractAttribute]
class PostalAddressExtendedContract extends PostalAddressContract
{
    StreetName streetName;
}
 
or do we just add the new fields to the original class? but if I add them to the original class, is it ok that the first service will start seeing fields that it's not going to use? i want to know if it's a best practice to only show the fields needed for the service or if it's better to add everything and it's up to them to use it or ignore it?

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

November Spotlight Star - Khushbu Rajvi

Congratulations to a top community star!

Forum Structure Changes Coming on 11/8!

In our never-ending quest to help the Dynamics 365 Community members get answers faster …

Dynamics 365 Community Platform update – Oct 28

Welcome to the next edition of the Community Platform Update. This is a status …

Leaderboard > Finance

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans