简体   繁体   English

86 / 5.000 Çeviri sonuçları 我创建了我的模型,但我不知道如何创建 Dto。 我该怎么做?

[英]86 / 5.000 Çeviri sonuçları I created my model, but I don't know exactly how to create the Dto. How can I do it?

My intern and I created my model in relation to other tables.我和我的实习生创建了与其他表格相关的模型。 Now I need to create the Dto.现在我需要创建 Dto。 I'm not completely sure and I'm a little confused when creating relationship structures.我不完全确定,在创建关系结构时我有点困惑。 I need to create the Dto of my model.我需要创建模型的 Dto。 How can I create it without error?我怎样才能没有错误地创建它? Can you help me?你能帮助我吗?

My Model: Activity.cs我的模型:Activity.cs

[Table("Activity")]
public class Activity : FullAuditedEntity<int>
{
    public int ScenarioId { get; set; }
    public int BrandId { get; set; }
    public int CategoryId { get; set; }
    public int ProductId { get; set; }
    public int ProductCodeId { get; set; }

    public decimal DiscountedPrice { get; set; }
    public decimal Discount { get; set; }
    public decimal PromoMargin { get; set; }

    [Description("Covid Connected Shutdown Status")]
    public bool ShutdownStatus { get; set; }




    [ForeignKey("BrandId")]
    public virtual Brand Brand { get; set; }

    [ForeignKey("CategoryId")]
    public virtual Category Category { get; set; }

    [ForeignKey("ProductId")]
    public virtual Product Product { get; set; }

    [ForeignKey("ProductCodeId")]
    public virtual ProductCode ProductCode { get; set; }

    [ForeignKey("ScenarioId")]
    public virtual Scenario Scenario { get; set; }

I need to create ActivityDto.cs我需要创建 ActivityDto.cs

[AutoMapFrom(typeof(Activity))]
public class ActivityDto : FullAuditedEntity<int>
{
    [Required]
    public decimal ActivityName { get; set; }
    [Required]
    public decimal DiscountedPrice { get; set; }
    [Required]
    public decimal Discount { get; set; }
    [Required]
    public decimal PromoMargin { get; set; }
    [Required]
    [Description("Covid Connected Shutdown Status")]
    public bool ShutdownStatus { get; set; }
}

How can i create other relations dto too.我如何也可以创建其他关系 dto。 Do I need to keep their Id in the form of a new list?我是否需要以新列表的形式保留他们的 ID?

Your Dto Class is inherited by FullAuditedEntity<int> .您的 Dto 类由FullAuditedEntity<int>继承。 It must be inherited like this FullAuditedEntityDto<int>它必须像这样继承FullAuditedEntityDto<int>

For the other relations, it is enough to describe relational entities id like this:对于其他关系,像这样描述关系实体 id 就足够了:

public id BrandId { get; set; }
public id CategoryId { get; set; }
.
.
.
.

Good luck!祝你好运!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在视图中调用我在模型中创建的函数 - How do i call the function I created in my Model on the view 如何在我的 Angular 共享库中创建一个 model? - How do I create a model in my Angular shared library? 仅在首次在Rails 5中创建对象(模型)时,才如何调用方法? - How do I invoke a method only when my object (model) is first created in Rails 5? 如何创建功能模型? - How do I create a model of a function? 如何在模型中存储日期? - How do I stored a date in my model? 如何将模型导入控制台,以便可以从数据库中查找模型的实例? - How do I import a model into my console so that I can lookup instances of it from my db? 如何将模型连接/关联到视图? - How do I connect/relate my model to my view? 如何将新创建的对象分配给它在Rails中所属的模型 - How do I assign a newly created object to a model it belongs to in rails Web中的MVC:如果我不想在“模型”和“库”中出现“会话”,该如何使用? - MVC in web: How should I use 'session' if I don't wanna it appear in 'model' and 'library'? 使用Eloquent,如何过滤我的模型查询以仅包含今天创建的项目? - Using Eloquent, how do I filter my Model-query to include only items that were created today?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM