Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

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

21,559 views

Published on

Room metro #14 大阪のセッション資料です。

Published in: Technology
  • Be the first to comment

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

×