Successfully reported this slideshow.

Windows ストアーアプリで SQLite を使ってみよう

4

Share

Upcoming SlideShare
Active Record
Active Record
Loading in …3
×
1 of 18
1 of 18

More Related Content

Related Books

Free with a 14 day trial from Scribd

See all

Windows ストアーアプリで SQLite を使ってみよう

  1. 1. http://shinichiaoyagi.blogspot.jp/
  2. 2. http://www.sqlite.org/
  3. 3. class Person { [PrimaryKey, AutoIncrement] public int Id { get; set; } [MaxLength(20)] public string Name { get; set; } } using (var con = new SQLiteConnection( Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path, "AdressBook.db"))) { con.CreateTable<Person>(); con.Insert(new Person() { Name = "メトロ太郎" }); }
  4. 4. var persons = con.Query<Person>("select * from Person where Id = 1"); class Result { public string Name { get; set; } } var names = con.Query<Result>("select Name from Person where Id = 1");
  5. 5. var person = con.Table<Person>().Where(x => x.Id == 1).First();
  6. 6. con.Execute("update Person set Name='WindowsRT' where Id=1"); var person = con.Table<Person>().Where(x => x.Id == 1).First(); person.Name = "Metro"; con.Update(person);
  7. 7. var con = new SQLiteAsyncConnection( Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path, "AdressBook.db")); await con.CreateTableAsync<Person>(); await con.InsertAsync(new Person() { Name = "メトロ太郎" }); var person = await con.Table<Person>().Where(x => x.Id == 1).FirstAsync(); person.Name = "Metro"; await con.UpdateAsync(person); await con.ExecuteAsync("update Person set Name='WindowsRT' where Id=1"); var persons = await con.Table<Person>().ToListAsync();
  8. 8. http://blogs.msdn.com/b/windowsappdev_ja/archive/2012/07/25/roaming.aspx
  9. 9. try { var foamingfile = await Windows.Storage.ApplicationData.Current.RoamingFolder.GetFileAsync("AdressBook.db"); await foamingfile.CopyAsync(Windows.Storage.ApplicationData.Current.LocalFolder); } catch (FileNotFoundException) { } var localfile = await Windows.Storage.ApplicationData.Current.LocalFolder.GetFileAsync("AdressBook.db"); await localfile.CopyAsync(Windows.Storage.ApplicationData.Current.RoamingFolder);
  10. 10. http://msdn.microsoft.com/ja-jp/library/windows/apps/xaml/hh975357.aspx
  11. 11. http://www.microsoft.com/ja-jp/download/details.aspx?id=30674

×