We have two projects in our application:
- Web UI project (aspx pages).
- WCF project.
Both of these sections will further call the same BL and DAL layer. Here is the architecture:
Web Project:
WCF Project(which will be using REST):
Example of Business object and DTO mentioned above:
public class User
{
public int UserID { get; set; }
public string UserName { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
}
public class UserDTO
{
public int UserID { get; set; }
public string UserName { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
}
Is it worth to have a separate data transfer object UserDTO.cs for WCF REST layer? We are already having User.cs as a Business object which is being used by Web project, BL and DAL. Further, in our WCF REST layer we are using DTO just for input prams:
public MyResponse CreateUser(User user)
{
and from this method we are converting the DTO to Business object (i.e UserDTO to User.cs object) via some mapper and passing it to BL layer which accepts only Business objects and not DTO. i.e from the point WCF is passing the Business object to BL and DAL, it behaves exactly the way UI passes the Business object to BL and DAL layer.
Is there any practically advantage using 2 separate data transfer objects? I have asked this question because IMO this will be redundant and we should go with one data trasnfer object i.e. Business object for both the Web project and WCF project.