hello
i have the following table structure
- Course |________CourseDetails |_____________________Educators
earlier i created a service to get course with coursedetails works fine but when i added the Educators as a collection in coursedetails the program stops saying internal server error
my
function
in the interface ListResultDto<CourseListDto1> GetCourse(GetCoursesInput input);
in the service inheriting the interface public ListResultDto<CourseListDto> GetCourseNoEdu(GetCoursesInput input) { var courses = _courseRepository .GetAll() .Where(p => p.Type == CourseType.Live) .Include(p => p.CourseDetails) .WhereIf( !input.Filter.IsNullOrEmpty(), p => p.Name.Contains(input.Filter) ) .OrderBy(p => p.Name) .ToList();
return new ListResultDto<CourseListDto>(courses.MapTo<List<CourseListDto>>());
}
my dto for course
[AutoMapFrom(typeof(Course))] public class CourseListDto1 : FullAuditedEntityDto {
public string Name { get; set; }
public string CourseDesc { get; set; }
public string ARName { get; set; }
public string ARCourseDesc { get; set; }
public virtual ICollection<CourseDetailListDto> CourseDetails { get; set; }
}
My DTO for CourseDetail
public class CourseDetailListDto : FullAuditedEntityDto { public int CourseId { get; set; } public string Title { get; set; } public string CourseDesc { get; set; } public string CourseDetDesc { get; set; } public string Requirement { get; set; } public string Image { get; set; } public string ARTitle { get; set; } public string ARCourseDesc { get; set; } public DateTime StartDate { get; set; } public int Duration { get; set; } public string DurationUnit { get; set; } public int HrWeek { get; set; } public decimal Price { get; set; } public int CountReg { get; set; } public string CourseUrl { get; set; }
public virtual Educator educator { get; set; }
}
and my call in index.js
vm.courses = [];
function getCourse() {
courseService.getCourse({}).success(function (result) {
vm.courses = result.items;
})
;
}
gives internal server error data
if i comment the public virtual Educator educator { get; set; } in the coursedetails it work fine , if i uncomment it fails
please tell me how to define vm.course in index to recieve multi level
3 Answer(s)
-
0
Hi,
You shouldn't use entities in your DTOs. Define a dto class for Educator and use it instead of
public virtual Educator educator { get; set; }in CourseDetailListDto.
Markdown is supportedCopy & paste or drag & drop images (max 30 MB per image) -
0
i changed the statement
public virtual Educator educator { get; set; }
to
public virtual EducatorListDto educator { get; set; }
replacing the entity with a
[AutoMapFrom(typeof(Educator))] public class EducatorListDto : FullAuditedEntityDto { public virtual string Salute { get; set; } public virtual string Name { get; set; } public virtual string Qualification { get; set; } public virtual int Experience { get; set; } public virtual string ARName { get; set; } public virtual string ARQualification { get; set; } public virtual string Image { get; set; } public virtual int Ratings { get; set; } }
i get the folowing error
An exception of type 'AutoMapper.AutoMapperMappingException' occurred in Abp.dll but was not handled in user code
can you please tell me how to address this brother
Markdown is supportedCopy & paste or drag & drop images (max 30 MB per image) -
0
Hi,
There must be a more detailed error message in Logs.txt file under your web project. Can you send it ?
Markdown is supportedCopy & paste or drag & drop images (max 30 MB per image)