Error handling in map operation of ABP
When mapping an entity object into dto in ABP, the entity defines an object of type long. In dto, there is an object with the same name, but the type is guid,
// StudentEntity
public class StudentEntity
{
public Guid RelatedStudentId
{
get; set;
}
}
// StudentDto
public class StudentDto
{
public Guid StudentId
{
get; set;
}
public Long RelatedStudentId
{
get; set;
}
}
Take studententity and studentdto for example. Due to the change of business, when the back-end modifies the database and does not change the front-end code for the time being,
Directly map the relatedpatientid in entity to the studentID in dto , In this way, an error will occur when mapping, indicating that the type conversion error is wrong, and the data of the guid cannot be assigned to long,
CreateMap<StudentEntity, StudentDto>()
.ForMember(d => d.StudentId, map => map.MapFrom(o => o.RelatedStudentId))
At this time, the entity’s guid type relatedpatientid will be mapped to the long type relatedpatientid in dto,
This kind of data definition should be avoided in map operation.
div>
Read More:
- Easynvr operation log reports an error. Fatal error: concurrent map read and map write troubleshooting
- Map to vector pair map.second sort
- Android 9 (P) recovery upgrade Map of ‘@/cache/recovery/block.map’ failed problem analysis guide
- [go] solve the fatal error of go: concurrent map writes map non concurrent security
- Struts 2 encapsulates form data into list and map sets
- JSON and map convert to each other (using fastjson)
- [Vue warn]: Error in nextTick: “TypeError: Cannot read property ‘map‘ of null“
- Common problems of shadow map in OpenGL
- Common attributes and methods of list and map in Dar
- OpenGL cube texture map
- Transformation of JS map and JSON
- chrome net_error_map
- NoClassDefFoundError: org/codehaus/jackson/map/ObjectMapper
- Quickly convert map to ordered array
- BUG: Bad page map in process XXX pte:800000036fae6227 pmd:35be8c067
- How to get all the keys of map by golang
- WordPress website map sitemap.xml error repair
- [Solved] Unity Error: Assertion failed on expression: ‘m_ErrorCode == MDB_MAP_RESIZED
- Lambda set to map duplicate key error solution
- #An error is reported by the chart map component of renfast framework