Tôi không chắc liệu mình có vấn đề về luồng hay không. Khi tải trang, tôi đang thực hiện hai yêu cầu Ajax để tải thêm một số dữ liệu từ API của bên thứ ba. Dưới đây là ý nghĩa của từng phương thức được gọi là:Sự cố phát tán AutoMapper (Thiếu cấu hình bản đồ loại hoặc bản đồ không được hỗ trợ)?
private List<CaseCommentModel> GetCaseCommentModels(string caseId) {
var comments = CaseService.GetAllCaseCommentsByCaseId(caseId);
Mapper.Reset();
Mapper.CreateMap<CrmCaseComment, CaseCommentModel>();
var caseCommentModels = Mapper.Map<List<CrmCaseComment>, List<CaseCommentModel>>(comments);
return caseCommentModels;
}
private List<CaseAttachmentModel> GetCaseAttachmentModels(string caseId) {
var attachments = AttachmentService.GetAttachmentsByParentId(caseId);
Mapper.Reset();
Mapper.CreateMap<CrmAttachment, CaseAttachmentModel>();
var caseAttachmentModels = Mapper.Map<List<CrmAttachment>, List<CaseAttachmentModel>>(attachments);
return caseAttachmentModels;
}
Đôi khi cả hai câu trả lời đều thành công. Nhưng, nếu tôi làm mới trang, đôi khi người ta sẽ thất bại với các ngoại lệ sau đây:
Missing type map configuration or unsupported mapping
Tôi có thể đi từ cả hai yêu cầu thành công với một thất bại mà không thực hiện bất kỳ thay đổi mã; tất cả những gì cần làm là làm mới trang. Đây có phải là vấn đề luồng hay tôi đang sử dụng trình ánh xạ không chính xác?
+1 cho cấu hình động – zidane