Tag: Sqlite

WinPhone, CaliburnMicro, and Sqlite

Where is TDD in WP dev?

Simple class can be tested in SilverLight.NUint project, (must modify guid to make it look as WP project), but most WP classes are not TDD friendly, e.g., IsolatedStorageFile (another MS no-interface sealed class), how can we make IsolatedStorageFile.GetUserStoreForApplication() run in non-WP environment?  So shameful doing F5 for testing every single code change.

Tried to switch to Sqlite on WP7 project, same issue, can’t run in out of simulator, but, sqlite is much popular, it’s also supported in iPhone, while Apple suggests developer go to core-data.

Anther bad news, no NHibernate for Sqlite on WP yet.

Powerful Caliburn.Micro

Convention binding in CaliburnMicro is amazing, cal:AppBarButton can be easily hooked up to the method with then same name as the message sent by button.

Url get parameter auto-wiring works like a charm in those decedents from Screen base class. Wiring won’t be ready in ctor, must wait in OnInitialize.

Navigation service is handy, but View-based style binding still looks awful to me, passing object instead of values to the new opened view/viewmodel is very difficult, I had to back to evil global/static class to pass object around, ugly, but very easy to use.

OnViewLoaded method is great, a perfect place to hook up event handle to view.

‘Unrecognized char’ issue in sqlite

Got this issue when trying insert string using sqlite_execute, suggestion is to use sqlite3_prepare/bind_text/step/reset instead.

string sql = string.Format("INSERT INTO my_table (id, title, summary ) VALUES({0},?,?);",

Sqlite3.Vdbe stmt = null;

_rc = Sqlite3.sqlite3_prepare_v2(_db, sql, -1, ref stmt, Sqlite3.SQLITE_NULL);
if (_rc != Sqlite3.SQLITE_OK) { throw new SqliteException(Sqlite3.sqlite3_errmsg(_db) ); }

_rc = Sqlite3.sqlite3_bind_text(stmt, 1,  Title, -1, Sqlite3.SQLITE_STATIC);
if (_rc != Sqlite3.SQLITE_OK) { throw new SqliteException(Sqlite3.sqlite3_errmsg(_db)); }

_rc = Sqlite3.sqlite3_bind_text(stmt, 2,  Summary, -1, Sqlite3.SQLITE_STATIC);
if (_rc != Sqlite3.SQLITE_OK) { throw new SqliteException(Sqlite3.sqlite3_errmsg(_db)); }

_rc = Sqlite3.sqlite3_step(stmt);
if (_rc != Sqlite3.SQLITE_DONE) { throw new SqliteException(Sqlite3.sqlite3_errmsg(_db)); }

_rc = Sqlite3.sqlite3_reset(stmt);
if (_rc != Sqlite3.SQLITE_OK) { throw new SqliteException(Sqlite3.sqlite3_errmsg(_db)); }

It’s strange that sqlite3_step returns 101 instead of 0.