0

我有很多使用 SQL、SQLite 和 C# 在 Windows 上编写数据库的经验,试图找出使用 MonoTouch.Dialog 进行数据库操作的最佳方法,我的最后一个 C# 项目将所有表中的所有记录加载到镜像的类中数据库中的表带有一个名为dirty(bool) 的额外字段来计算需要更新的内容。

我猜我应该对 MonoTouch.Dialog 做同样的事情,当 dialogviewcontrollers 被关闭时更新 SQLite?,明智的做法是将表类包装到 dialogviewcontrollers 类的类中,因为这似乎是正确的方法,例如为每个 dialogviewcontroller 创建单独的类,并包含里面的数据。

向上和向下移动主详细信息视图(例如传递 ID)的最佳方法是什么。

谢谢

亚历克斯

4

1 回答 1

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.

于 2012-06-08T02:18:38.370 回答