Many to many relationship mapping makes the app crash and exit with "Access violation"
sekulicb opened this issue · comments
sekulicb commented
Describe the bug
Case where one class or record "A" has property of another type "B", and that same type "B" has property of type "A"
Declaration code
public record RoleDto(
int Id,
string Name,
bool IsAdmin,
IEnumerable<PermissionDto>? Permissions
) : BaseDto(Id);
public record PermissionDto(
int Id,
string Name,
IEnumerable<RoleDto> Roles
) : BaseDto(Id);
What have I tried:
- [Mapper(UseReferenceHandling = true)]
- [MapperIgnoreTarget(nameof(PermissionDto.Roles))] on public static partial PermissionDto MapToDto(Permission entity) method
What worked:
- Removing IEnumerable Roles property
Environment (please complete the following information):
- Mapperly Version: [3.5.1.]
- Nullable reference types: [enabled]
- .NET Version: [e.g. .NET 8.0.100]
- Target Framework: [.net8.0]
- Compiler Version: [e.g. 4.8.09037]
- C# Language Version: [e.g. 12.0]
- IDE: [Visual Studio v17.8.1]
- OS: [Windows 10 ]
Additional context
Instead of removing property, I would like to keep it.
sekulicb commented