0

This is my Entity:

public class CouponEntity
{
    public int CouponId { get; set; }
    public int CompanyNumber { get; set; }
    public string Name { get; set; }
    public string FileName { get; set; }

    public string CompanySlug
    {
        get
        {
            return COMMONCONSTANTS.URL_COMPANY + "/" + this.CompanyNumber;
        }
    }
}

And the following is my DTO:

public class CouponDto
{    
    [DataMember]
    public string CompanySlug { get; set; }
    [DataMember]
    public string FileName { get; set; }
    [DataMember]
    public string Name { get; set; }
}

My question is: does using Mapper.Map<IEnumerable<CouponEntity>, IEnumerable<CouponDto>>(lstProducts) greatly affect performance?

I got the following from the AutoMapper creator somewhere on the Internet:

DTO is a strict projection of the data model. No business logic in mapping 99% "Auto" - restrict customization to minimum Prefer LINQ projection

So, is this what should be avoided? Is there a better way to accomplish this?

1 Answer 1

1

In this scenario, using AutoMapper is unlikely to have a noticeable impact on performance. Creating the map, Mapper.CreateMap(), does tend to have an impact on performance, so be sure that you only call CreateMap() once when the application starts.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.