Really, I spend more time to understand Poco and DTO with a lot of confusion and questions. After understanding I decide to post immediately to my blog.

What is POCO?

  • POCO stands for Plain Old CLR Object.It provides freedom to define an object model in which objects does not inherit from specific base classes
  • POCO data classes, also known as persistence-ignorant objects, it refers to an object do not have any persistence concerns
  • It mainly has a control over implementation and design
  • A POCO is a BO (Business object). We can implement validation and any other business logic can occur here.
  • POCO have state and behavior.

What is Persistence ignorance in POCO

It means (layers) it does not depend on the design of the database, IE., type of database, type of database object.

Example for POCO Model

public class Customer {
public int CustomerID
{ get; set; }
public string CustomerName
{ get; set; }
public string CustomerGender
{ get; set; }
}

What is DTO?

  • Stands for Data Transfer Object, its Main purpose is to transfer data.
  • It just stores data. It is a lightweight container used for transferring data between layers.
  • There will be no effect on application if entity changed or modified (based on the Database structure)

Example for DTO Model

public Customer()
{
CustomerID = Int_NullValue;
CustomerName= String_NullValue;
CustomerGender = String_NullValue;
Address = String_NullValue;
}
Difference between POCO and DTD

  • POCO has state and behavior, but DTD has only state (it does not contain behavior IE., method)
  • POCO describes an approach to programming, where DTO is a pattern that is used to move data using objects.