SlideShare uses cookies to improve functionality and performance, and to provide you with relevant advertising. If you continue browsing the site, you agree to the use of cookies on this website. See our User Agreement and Privacy Policy.
SlideShare uses cookies to improve functionality and performance, and to provide you with relevant advertising. If you continue browsing the site, you agree to the use of cookies on this website. See our Privacy Policy and User Agreement for details.
Successfully reported this slideshow.
Activate your 14 day free trial to unlock unlimited reading.
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.
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.
var person = con.Table<Person>().Where(x => x.Id == 1).First();
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.
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();