时间:2021-07-01 10:21:17 帮助过:2人阅读
使用SQL访问一个数据的操作是
select * from Table where ID=1
通过封装一般简化为类似如下的操作
DB.Find( "Table", 1);
在 iBoxDB 中借助C#索引器,操作简化到
DB["Table",1];
一个简单但完整使用Xamarin结合iBoxDB开发Android应用的例子
var db = new DB (1, System.Environment.GetFolderPath (
System.Environment.SpecialFolder.Personal));
db.GetConfig ().EnsureTable ("Table", new Dictionary<string,object>{ { "ID",0 } });
var auto = db.Open ();
using (var box = auto.Cube ()) {
for (int i = 0; i < 100; i++) {
box ["Table"].Insert (
new Dictionary<string,object> {
{ "ID",i }, { "Name", "Name-" + i }
});
}
box.Commit ().Assert ();
}
button.Click += delegate {
button.Text = auto ["Table", count++ % 100].ToString();
};
运行

只需要几行代码结合索引器,超级方便实现一个移动数据库应用。
使用C#索引器轻松访问iBoxDB中的数据
标签: