Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Recommendation is that you should just have one DTO class for each entity <strong><em>suffixed with DTO</em></strong> e.g. <code>CustomerEntryDTO</code> for the <code>Customer</code> <code>entity</code> (but you can certainly use inheritance hierarchies as per choice and requirements).</p> <p>Moreover, Add a abstract <code>DTOBase</code> kind of base class or an interface; and do not use such deep inheritance heirarchies for each Address, Account and other properties to be included in child DTOs. Rather, include these properties in the same <code>CustomerEntryDTO</code> class (if possible) as below:</p> <pre><code>[Serializable] public class CustomerEntryDTO : DTOBase, IAddressDetails, IAccountDetails { public int Id { get; set; } public string Name { get; set; } public AddressDetails Address { get; set; } //Can remain null for some Customers public ICollection&lt;AccountDetails&gt; Accounts { get; set; } //Can remain null for some Customemer } </code></pre> <p>Moreover, your DTOs <em>should</em> be serializable to be passed across process boundaries.</p> <p>For <em>more</em> on the DTO pattern, refer below articles:</p> <p><a href="http://martinfowler.com/eaaCatalog/dataTransferObject.html" rel="nofollow noreferrer">Data Transfer Object</a></p> <p><a href="http://msdn.microsoft.com/en-us/library/ff649585.aspx" rel="nofollow noreferrer">MSDN</a></p> <p><strong>Edit:</strong> In case you don't want to send certain properties over the wire (I know you would need to that conditionally so would need to explore more on this), you can exclude them from the Serialization mechanism by using attributes such as <a href="http://msdn.microsoft.com/en-us/library/system.nonserializedattribute%28v=vs.100%29.aspx" rel="nofollow noreferrer"><code>NonSerialized</code></a> (but it works only on fields and not properties, see workaround article for using with properties: <a href="https://stackoverflow.com/questions/7693391/nonserialized-on-property">NonSerialized on property</a>). You can also create your own custom attribute such as <code>ExcludeFromSerializationAttribute</code> and apply it to properties you don't want to send every time over wire based on certain rules/conditions. <strong>Also see:</strong> <strong><a href="https://stackoverflow.com/questions/4094985/conditional-xml-serialization">Conditional xml serialization</a></strong></p> <p><strong>Edit 2:</strong> Use interfaces for separating the different properties in the one <code>CustomerEntryDTO</code> class. See the Interface Segregation Principle on Google or MSDN. I will try to put a sample explanation later.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload