Question

I can't get my head around this error. I'm coming in another developers project and he has used the code provided to retrieve several reports and all functions as it should , however I keep getting the error in the title when I created a similar report.

Where and what needs to be in place to make this mapping work correctly. Please advise if more code is needed. Also note it's an ASP.NET MVC 3 application

The controller....

    case ReportType.BS_Report:
            {
                model.BSReport = "Company name";

                var records = _docsRepo.PaginatedBS_Reports(model.BSReport,
                                                                            model.From,
                                                                            model.To,
                                                                            currentPageIndex,
                                                                            pageSize,
                                                                            out totalRecords);

                var TimeRec = Mapper.Map<IList<BS_Report>, IList<BSModel>>(records);

                var TimeRecdModel = TimeRec.ToReportPagedList(currentPageIndex,
                                                                            pageSize,
                                                                            model,
                                                                            totalRecords);

                return PartialView("BS_Report", TimeRecdModel);
            }

Everything works as it should until it reaches this line...

   var TimeRec = Mapper.Map<IList<BS_Report>, IList<BSModel>>(records);

BS_Report class...

     public class BS_Report : ReportBase
{
    public int Id { get; set; }
    public string EquipmentID { get; set; }
    public string EquipmentDescription { get; set; }
    public DateTime? CreatedOn { get; set; }
    public string CustomerName { get; set; }
}

BSModel....

      public class BSModel : ReportBaseModel
{

    public int Id { get; set; }
    public string EquipmentID { get; set; }
    public string EquipmentDescription { get; set; }
    public DateTime? CreatedOn { get; set; }
    public string CustomerName { get; set; }
 }

Other report case uses exact same code...

     case ReportType.Full_Report:
            {
                var records = _docsRepo.PaginatedFullReportReports(model.ReportedOn,
                                                                            model.From,
                                                                            model.To,
                                                                            currentPageIndex,
                                                                            pageSize,
                                                                            out totalRecords);

                var TimeRecord = Mapper.Map<IList<FullReport>, IList<FullReportModel>>(records);

                var TimeRecordModel = TimeRecord.ToReportPagedList(currentPageIndex,
                                                                            pageSize,
                                                                            model,
                                                                            totalRecords);

                return PartialView("FullReport", TimeRecordModel);
            }
Was it helpful?

Solution

You will probably need to 'Create' a mapping for your new report. Search the codebase for some calls to 'CreateMap' that operate on whatever report type the previous developer had used. You will likely need to create one for your BS_Report type.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top