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:

  1. 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.
  2. 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.
  3. 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

Popular posts from this blog

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -