As I'm still somewhat of a newcomer to all things DPI / C# and similar, I'm currently struggling a bit with the best way to achieve my goals.
Prism/Unity and Azure Mobile Services are working, no problems there. My question arises from being stumped on how to properly combine the two mechanics.
Basically, I have a model e.g. Group which in turn has several GroupMember. With a foreign-key-alike and some LINQ-magic I can get the Group and its members like so:
Group group = (await groupsTable.Where(g => g.Id == Id).ToListAsync()).First();
List<GroupMember> groupMembers = await groupMembersTable.Where(gm => gm.group_id == group.Id).ToListAsync();
Hereby the Group and GroupMembers instantiated from the underlying SQLite-Table (I'm using offline sync) with the data from the table queries.
The tables I get from an MobileService instance which I registered with the IUnityContainer (so I can exchange the mobile service with a mock one for unit tests).
However, what do I do if I want to register the IUnityContainer in the model (e.g. to do something like GetSiblings() or GetChildren())? Basically, I need access to the IUnityContainer inside the models but due to the way they're instantiated, the DependencyInjection gets bypassed and something like:
[Dependency]
public IUnityContainer _container { get; set; }
remains null. I've also read that it's considered bad to make the container static, so...
... also I don't think that something like:
foreach(var member in groupMembers) {
member._container = container;
}
is the way to go. Any hints?