用于CRUD ASP.NET Core的最佳实践设计DTO?

时间:2018-11-14 02:25:21

标签: c# asp.net crud dto

我有DTO层在API层,数据层和其他层之间传输数据 我对C#中的DTO设计模式有疑问

示例:

public class ProductDTO{
    public int Id {get;set;}
    public string Name {get;set;}
    public decimal Price {get;set;}
    public int CategoryId {get;set;}
    public string Desc {get;set;}
}

我应该将此ProductDTO拆分为CRUD吗?

示例:

public class ProductInsertDTO
{
    public string Name {get;set;}
    public int CategoryId {get;set;}
}

在传输数据时用于ProductDTO(500字节)和ProductInsertDTO(293字节)

1 个答案:

答案 0 :(得分:0)

不。对于如此少量的数据,网络开销将成为更大的问题。经验法则是:避免“聊天”交流。更好地在一个呼叫中交换更多内容,而不是将其拆分为多个呼叫。

相关问题