Xamarin android c#:SQLiteAsyncConnection

时间:2015-12-02 07:54:18

标签: c# android database

我目前正在使用SQLiteAsyncConnection进行数据库编码。 我可以每秒近200行创建并轻松插入数据库..

我的问题......读取数据库..是的,这听起来很愚蠢..但我需要逐行读取而不是将整个表转储到变量中..

正常的SQL编码有它.. 例如

string Oldfolder = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal);
        Oldfolder = Oldfolder + "/TheDatabase.db";
        SQLiteDatabase OldMydb = SQLiteDatabase.OpenDatabase(Oldfolder , null, DatabaseOpenFlags.OpenReadwrite );
        ICursor oldCheck = OldMydb.Query ("TheTable", null, null, null, null, null, null);

然后你所要做的就是

oldCheck.GetString (oldCheck.GetColumnIndexOrThrow ("IDT"))
oldCheck.MoveNext();

现在有人可以帮助解决Async版本吗?

这就是我插入....

var conn = new SQLiteAsyncConnection (System.IO.Path.Combine (folder, "TheDatabase.db"));
conn.CreateTableAsync<TheTable> ().ContinueWith (t => {});
TheTable myLine = new TheTable {
        TheGroup = myGroupName,
        TheTime = myMessageTime,
        TheMessage = myTextMessage,
        };
conn.InsertAsync (myLine).ContinueWith (t => {});

0 个答案:

没有答案