Using RIO and Sqlite-net in MvvmCross -
in excellent mvvmcross-library can use rio binding prevent unreadable code:
public inc<string>title = new nc<string>();
then can read , write values using title.value. makes models more readable.
normally, property written as: private string _title;
public string title { { return _title; } set { _title = value; raisepropertychanged("title"); } }
but when want use sqlite-net, these fields cannot streamed database because not basic types getter , setter.
i can think of few options how around that:
- make new simple object similar model, direct db-fields. , create simple import-export static method on model. prevent struggling complex model-code never needs relate actual database.
- make sqlite-net understand reading nc-fields. read code of mapper, looks going lot of work because relies on getter-setter. did not find way insert custom mapping type, generic.
- remove rio , put in code myself instead of relying on rio.
maybe has advice?
thanks stuart. thought, did implement way: (db) models not contain rio. viewmodels do, , reference model db-compatible.
so, posterity following tips: - not use rio in models need database-backed. - reference models in viewmodels. in binding can use . (dot) reference model.
this keeps them nicely separated. gives advantage: if need reuse model (because same object might displayed twice on screen), under different circumstances, easier handle situaties find instantiated model.
Comments
Post a Comment