showing result here the error comes

i am getting this error while using mapping to source to destination.

AppointmentStatuses = The metadata for 'EntityFrameworkDynamicProxies-Appointments' is invalid. If you are debugging a minidump, you may be able to fix this problem by collecting a new minidump with heap and evaluating the expression again.

and this only comes when code reaches on

public ActionResult Approve(int? id)
        {
            if (id == null)
            {
                return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
            }
            var AppointmentRequest = db.Appointments.Where(p => p.AppointmentID == id).Include(m => m.VisitRequests).Include(m => m.AppointmentStatuses).FirstOrDefault();
            if (AppointmentRequest == null)
            {
                return HttpNotFound();
            }

            if (AppointmentRequest.AppointmentTypeID != 2 && !rp.IsUserInRole(UserName, "ApproveOfficialAppointment"))
            {
                TempData["error"] = "لا تملك صلاحية اعتماد المواعيد الخاصة والرسمية";
                return RedirectToAction("Requests");
            }
            if (AppointmentRequest.AppointmentTypeID == 2 && !rp.IsUserInRole(UserName, "ApproveAppointment"))
            {
                TempData["error"] = "لا تملك صلاحية اعتماد المواعيد غيرالرسمية";
                return RedirectToAction("Requests");
            }

            var vmodel = Mapper.Map<ApproveAppointmentViewModel>(AppointmentRequest);
            vmodel.AppointmentStatuses = new List<ApproveAppointmentStatusViewModel> { vmodel.AppointmentStatuses.OrderByDescending(s => s.ValidFrom).FirstOrDefault() };
            return View(vmodel);

        }

The error comes on this line

  var vmodel = Mapper.Map<ApproveAppointmentViewModel>(AppointmentRequest);

before this line AppointmentRequest having all data accurate but when it reaches on Mapping line the error comes with stackoverflow exception.

0 Answers