0

My intern and I created my model in relation to other tables. Now I need to create the 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. How can I create it without error? Can you help me?

My Model: 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

[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. Do I need to keep their Id in the form of a new list?

1
  • "Do I need to keep their Id in the form of a new list?" What do you mean by that?
    – aaron
    Mar 17, 2022 at 9:24

1 Answer 1

0

Your Dto Class is inherited by FullAuditedEntity<int>. It must be inherited like this FullAuditedEntityDto<int>

For the other relations, it is enough to describe relational entities id like this:

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

Good luck!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.