0

I have a lot of experience of writing databases on Windows with SQL, SQLite and C#, trying to work out the best way to do database operations with MonoTouch.Dialog, my last C# project loaded all the records from all the tables into classes that mirrored the tables in the database with an extra field called dirty(bool) to work out what needed to be updated.

I am guessing that I should do the same with MonoTouch.Dialog with SQLite updates when the dialogviewcontrollers are being closed?, it is wise to to wrap the table classes into the classes for the dialogviewcontrollers classes as this seems to be the right way to go, e.g. create individual classes for each dialogviewcontroller, and contain the data inside.

What is the best method for moving up and down master detail views e.g. passing ID's.

thanks

Alex

1 Answers1

0

In my current MT.D project I define a service layer that handles database access. I subclass DialogViewController to pass the id of the appropriate database row when e.g. opening a new form to edit the object. The new DVC is then responsible for any CRUD operations against the database via the service layer.

If the DVC updates the database, the service layer raises an event with an argument containing the modified object. The parent DVC event handler is notified of changes to the data and can update the UI appropriately. This relies on the MT.D sections and elements being available in the DVC so when creating e.g. elements I store them in a Dictionary that is indexed by the data object id.

For me this provides a sufficiently decoupled architecture and I assemble the app using the Funq DI framework (needs to be recompiled for MonoTouch). I'm interested to know how others handle this within a MT.D app.

David Clarke
  • 12,888
  • 9
  • 86
  • 116