Advertisement
Guest User

Untitled

a guest
Jul 21st, 2017
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.20 KB | None | 0 0
  1. public class AnrodidSqlite { string GetPath()
  2. {
  3. try
  4. {
  5. var databaseName = "mydb";
  6. var sqliteFilename = $"{databaseName}.db3";
  7. var documentsPath = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
  8. var path = Path.Combine(documentsPath, sqliteFilename);
  9.  
  10. if (File.Exists(path))
  11. {
  12. File.Delete(path);
  13.  
  14. }
  15. using (File.Create(path))
  16. {
  17. var connection= new SQLiteConnection(path);
  18. connection.CreateTable<Location>();
  19. }
  20.  
  21. return path;
  22. }
  23. catch (Exception ex)
  24. {
  25. throw;
  26. }
  27. }
  28.  
  29.  
  30.  
  31.  
  32. public SQLiteAsyncConnection GetAsyncConnection()
  33. {
  34. var path = GetPath();
  35. var conn = new SQLiteAsyncConnection(path,SQLiteOpenFlags.ReadWrite);
  36. return conn;
  37. }
  38.  
  39. public class LocationDal{
  40. public async Task SaveLocation(SearchCriteria searchCriteria)
  41. {
  42. try
  43. {
  44.  
  45. var originCity = searchCriteria.OriginCity;
  46. await _database.InsertAsync(destinationCity);
  47. }
  48. }}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement