Long form, TL;DR below
I'm currently developing a game using Zenject and designed my UI and game architecture very similar to a web app where there are IConversationRepository
-Interfaces providing access to data like Conversation
s with methods like GetConversationById(...)
.
So far, the Interfaces are implemented by dummies that return hardcoded data, but that has to change when I proceed further.
If this were a web application, I would just use an ORM and let it handle the querying and loading of objects, so my question is whether this also exists for Unity / Zenject and if not, what the proper way is to implement data access when using Zenject.
UPDATE (in response to helpful discussion with @Fattie)
What I am basically interested in is a generic way to load objects with references to others, and being able to query for them.
As an example, imagine a Conversation
object that holds many ConversationItem
s which each have a Speaker field of type Person
. I would then like to be able to perform operations like this:
var someSpeaker = personRepository.getById(100);
var conversation = conversationRepository.getById(0);
if (conversation.items[0].speaker == someSpeaker) {
// I know, in this example this behaviour could be moved
// into a method of Person to avoid the check for identity
// but I hope the idea is understandable.
}
What's important here is that if the speaker is the same for multiple SpeechItem
s, the objects referenced of each should be the same as well, which makes simply deserializing JSON infeasible.
TL;DR Is there something like an ORM that can be used to implement the Repository pattern? If not, how should I access data?