نکته تکمیلی
در صورتیکه به زمانِ الان، برای پارامتر هاتون نیاز داشتید اونو از طریق سرویس پاس بدید و متغیر رو داخل Profile به این صورت تعریف نکنید:
چون همون بار اول که پروژه اجرا میشه، مقدار دهی میشه و زمانش تغییر پیدا نمیکنه، DateTime.Now باید هربار از طریق سرویس از نو مقداردهی بشه.
public class MappingProfile : Profile { var now = DateTime.Now; }
public class MappingProfile : Profile { DateTime now = default; }
return _products .AsNoTracking() .ProjectTo<ProductInfoViewModel>( configuration: _mapper.ConfigurationProvider, parameters: new { now = DateTime.Now } ).SingleOrDefaultAsync(x => x.Id == id);