Base solution for your next web application
Open Closed

Whats the use of FullAuditedEntityDto in DTOs? #4184


User avatar
0
manojreddy created

Hi,

Why do We inherit from FullAuditedEntityDto? I don't see any use for this? because in the code mentioned I get CreationTime, CreatorUserId, DeleterUserId, DeletionTime, IsDeleted, LastModificationTime and LastModifierUserId columns proper values on edit, create and delete case if I use the same Dto for all action?

Please let me know what difference between a Dto inheriting from FullAuditedEntityDto and not inheriting from FullAuditedEntityDto . Could you please explain the difference between these two cases with some practical examples.

public async Task<int> CreateTest(TestDetailsDto input)
	{
		int TestId = await InsertAndGetIdAsync(ObjectMapper.Map<Test>(input));

		return TestId;
	}
	
	public class Test : FullAuditedEntity
    {
        public const int NVarcharLength20 = 20;
        public const int NVarcharLength30 = 30;
        public const int NVarcharLength50 = 50;

        [Required]
        [MaxLength(NVarcharLength20)]
        public virtual string TestCode { get; set; }

        [Required]
        [MaxLength(NVarcharLength30)]
        public virtual string TestName { get; set; }

        [MaxLength(NVarcharLength50)]
        public virtual string TestDesc { get; set; }
    }
	
	[AutoMap(typeof(Test))]
    public class TestUpdateDetailsDto
    {
        public string TestCode { get; set; }
        public string TestName { get; set; }
        public string TestDesc { get; set; }

        public int Id { get; set; }
    }

1 Answer(s)
  • User Avatar
    0
    alirizaadiyahsi created

    Hi @ManojReddy,

    For example you may want to show this properties on a grid. Then you can use it. But as you say, you don't need to use it for create/update/delete.