Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Many to many relationship mapping makes the app crash and exit with "Access violation" #1296

Closed
sekulicb opened this issue May 22, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@sekulicb
Copy link

sekulicb commented May 22, 2024

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 sekulicb added the bug Something isn't working label May 22, 2024
@sekulicb
Copy link
Author

image

@latonz
Copy link
Contributor

latonz commented May 22, 2024

Looks like a duplicate of #785. You need to ignore one of these two properties until #785 is supported.

@latonz latonz closed this as completed May 28, 2024
@latonz latonz closed this as not planned Won't fix, can't repro, duplicate, stale May 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants