locked
Slow performance of AutoMapper in WebAPI RRS feed

  • Question

  • User-137472927 posted

    Hi All,

     I am using AutoMapper in my WebaPI application to map the database objects to business objects like below:

    var products = statusId == null ? unitOfWork.GetRepoInstance<Infrastructure.Data.Product>().Get(
                    c => c.ProductID == productID && c.IsActive == true) :
                    unitOfWork.GetRepoInstance<Infrastructure.Data.Product>().Get(
                    c => c.ProductID == productId && c.IsActive == true && c.StatusId == statusId);
    
                var productsList = mapper.Map<List<BuisnessObjProduct>>(products);

    But the last line of code to map data object products to BuisnessObjProduct is taking around 100 seconds of processing time due to which UI page keeps loading in front of user

    Please advise how can I fix this issue in best way.

    Regards,

    Pratham

    Monday, May 24, 2021 3:33 PM

All replies

  • User-474980206 posted

    I suspect it’s the sql query and not automapper. You code has automapper execute the sql query.

    Monday, May 24, 2021 4:13 PM