Ejemplo n.º 1
0
 public static int SaveOptions(Options options)
 {
     using (SQLiteConnection conn = new SQLiteConnection(dbLocation))
       {
     return conn.Update(options);
       }
 }
Ejemplo n.º 2
0
 static OptionsRepository()
 {
     // Figure out where the SQLite database will be.
       var documents = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
       dbLocation = Path.Combine(documents, "timer_sqlite-net.db");
       using (SQLiteConnection conn = new SQLiteConnection(dbLocation))
       {
     conn.CreateTable<Options>();
     Options o = null;
     try
     {
       o = conn.Get<Options>(1);
     }
     catch (InvalidOperationException)
     {
       // Doesn't exist...
     }
     if (o == null)
     {
       // Create options... a bit contrived perhaps :)
       o = new Options();
       o.Seconds = 5;
       int rows = conn.Insert(o);
       if (rows == 0)
       {
     throw new InvalidOperationException("Can't create options!");
       }
     }
       }
 }