Should I decorate my classes / properties as DataContract / DataMember when I use them in WCF?

I have a structure with objects and a data access code. These objects are displayed in the database using NHibernate.

For example, my framework has a class Customer and Order:

public class Customer
{
      private Guid _id;
      private string _name;
      private IList<Order> _orders;

      public properties...
}


public class Order
{
     private Guid _id;
     private string _orderNumber;

     public properties...
}

I also have a WCF service with the PersistCustomer method. For example:

[ServiceContract]
public interface ICustomerService
{

      [OperationContract]
      void PersistCustomer(Customer customer);
}

This WCF has a link to my frame library.

I created a client application for the WCF service (simple console application) and it works!

The main thing I could not understand: why does it work without decorating my classes within the DataContract and their properties as DataMembers? And should I decorate them?

thanks

+3
source share
2

, . , , , , , .

, .NET , - , , , , , , .

+3

- , .NET 3.5 SP1 # (POCO).

, :

  • ASMX
  • WCF

Aaron Skonnards DataContracts ( POCO) .NET 3.5 SP1.

, @blowdart, DataContracts, DataMember, . DataContract, , , .

+3

Source: https://habr.com/ru/post/1716308/


All Articles