public void Setup(BenchmarkContext context) { Mapper.Reset(); Mapper.Initialize(cfg => { cfg.CreateMap <TaskDTO, Task>() .ForMember(dest => dest.Task1, opt => opt.MapFrom(src => src.Task)) .ForMember(dest => dest.Task_ID, opt => opt.MapFrom(src => src.TaskID)) .ForMember(dest => dest.StartDate, opt => opt.MapFrom(src => src.StartDate)) .ForMember(dest => dest.EndDate, opt => opt.MapFrom(src => src.EndDate)) .ForMember(dest => dest.Priority, opt => opt.MapFrom(src => src.Priority)) .ForMember(dest => dest.Project_ID, opt => opt.MapFrom(src => src.Project_ID)) .ForMember(dest => dest.Status, opt => opt.MapFrom(src => src.Status)) .ForMember(dest => dest.Parent_ID, opt => opt.MapFrom(src => src.Parent_ID)); cfg.CreateMap <ParentTaskDTO, ParentTask>() .ForMember(dest => dest.Tasks, opt => opt.Ignore()); cfg.CreateMap <User, UserDTO>(); cfg.CreateMap <UserDTO, User>(); cfg.CreateMap <Task, TaskDTO>() .ForMember(dest => dest.Task, opt => opt.MapFrom(src => src.Task1)) .ForMember(dest => dest.TaskID, opt => opt.MapFrom(src => src.Task_ID)) .ForMember(dest => dest.StartDate, opt => opt.MapFrom(src => src.StartDate)) .ForMember(dest => dest.EndDate, opt => opt.MapFrom(src => src.EndDate)) .ForMember(dest => dest.Priority, opt => opt.MapFrom(src => src.Priority)) .ForMember(dest => dest.Project_ID, opt => opt.MapFrom(src => src.Project_ID)) .ForMember(dest => dest.Status, opt => opt.MapFrom(src => src.Status)) .ForMember(dest => dest.Parent_ID, opt => opt.MapFrom(src => src.Parent_ID)) .ForMember(dest => dest.ProjectDTOName, opt => opt.MapFrom(src => src.Project.Project1)) .ForMember(dest => dest.ParentDTOName, opt => opt.MapFrom(src => src.ParentTask.Parent_Task)); cfg.CreateMap <ProjectDTO, Project>() .ForMember(dest => dest.Project1, opt => opt.MapFrom(src => src.ProjectName)); cfg.CreateMap <Project, ProjectDTO>() .ForMember(dest => dest.ProjectName, opt => opt.MapFrom(src => src.Project1)) .ForMember(dest => dest.TotalTaskCount, opt => opt.MapFrom(src => src.Tasks.Count)) .ForMember(dest => dest.lstUser, opt => opt.MapFrom(src => src.Users)) .ForMember(dest => dest.CompletedTaskCount, opt => opt.MapFrom(src => src.Tasks.Where(a => a.Status.ToUpper().Trim() == "COMPLETED").Count())); }); _appRepository = new TaskData(); _userData = new UserData(); _projectData = new ProjectData(); _userData.CreateUser(new User { FirstName = "SampleFName", LastName = "SampleLName", Employee_ID = 1 }); user = _userData._dbContext.Users.Where(a => a.Employee_ID == 1).FirstOrDefault(); _projectData.CreateProject(new Project { Project1 = "SampleProject", Priority = 1 }); project = _projectData._dbContext.Projects.Where(a => a.Project1 == "SampleProject").FirstOrDefault(); _appRepository.CreateParentTask(new ParentTask { Parent_Task = "SampleParentTask" }); parentTask = _appRepository._dbContext.ParentTasks.Where(a => a.Parent_Task == "SampleParentTask").FirstOrDefault(); _appRepository.CreateTask(new Task { Task1 = "SampleTask", Priority = 1, StartDate = DateTime.Now.Date, EndDate = DateTime.Now.Date.AddDays(1), Parent_ID = parentTask.Parent_ID, Project_ID = project.Project_ID }); task = _appRepository._dbContext.Tasks.Where(a => a.Task1 == "SampleTask").FirstOrDefault(); }