ky1e
ky1e
CC#
Created by ky1e on 11/18/2023 in #help
How to map Entity Framework entities containing circular references to DTOs?
i appreciate the input. i have considered looking closer at GraphQL because of many instances where various front-end views need similar, but slightly different, forms of some data (e.g. each view uses the same base entity but one view needs related entities a, b, c, while a different view needs related entities x, y, z) im not very knowledgeable about GraphQL. would using GraphQL eliminate my issue with circular references entirely (and thus resulting in my mapper classes working fine?), or would it eliminate my need for mapper classes, or is that more of an unrelated suggestion based on the app description?
31 replies
CC#
Created by ky1e on 11/18/2023 in #help
How to map Entity Framework entities containing circular references to DTOs?
probably a skill issue 😉
31 replies
CC#
Created by ky1e on 11/18/2023 in #help
How to map Entity Framework entities containing circular references to DTOs?
i'll prob create separate DTOs if im not able to find any better approach. i appreciate your guys input
31 replies
CC#
Created by ky1e on 11/18/2023 in #help
How to map Entity Framework entities containing circular references to DTOs?
i saw someone's solution posted online was to null out the circular references after querying the entity. seems janky
31 replies
CC#
Created by ky1e on 11/18/2023 in #help
How to map Entity Framework entities containing circular references to DTOs?
it's a large scale app with ~100 entities and tons of relationships amongst them. i pulled these two for the example because they are the most basic, but there are tons of instances where this comes up. another example would be Player and Game. in some cases, the Player is being queried and the Player's games are included. in other cases, the Game is queried and needs to include the Players. this doesn't seem like anything atypical to me... can't help but think there's some way to manage this better than avoiding it entirely. even if the answer is to create multiple entity -> DTO mapper classes for a single entity
31 replies
CC#
Created by ky1e on 11/18/2023 in #help
How to map Entity Framework entities containing circular references to DTOs?
not sure how you can assume i dont have any use for having Sport in the League DTO without knowing anything about the app. but im gonna guess the suggestion would be to create a separate DTO for that? i imagine that would get really messy. i dont recall having this issue with AutoMapper, which leads me to think that library handles this in some way, but could be misremembering since it was long ago
31 replies