Пример #1
0
 public void Update(VideoItem video)
 {
     using (connection.Lock())
     {
         connection.Update(video);
     }
 }
Пример #2
0
 public void Update(AlbumItem album)
 {
     using (connection.Lock())
     {
         connection.Update(album);
     }
 }
Пример #3
0
        private Recipe UpdateRecipe(Recipe recipe)
        {
            var row          = recipe.ToRecipeRow();
            var fields       = FieldExtractor.Extract(recipe);
            var searchFields = fields
                               .Where(x => x.IsSearchable)
                               .Select(x => new RecipeTextSearchRow
            {
                Id    = x.Id,
                Value = _queryParser.Parse(x.Value)
            })
                               .ToList();

            using (_connection.Lock())
            {
                //Remove all fields
                var mapping = _connection.GetMapping <RecipeTextFieldRow>();
                _connection.Execute($"DELETE FROM {mapping.TableName} WHERE RecipeId = ?", recipe.Id);

                //Recreate recipe and indices
                _connection.Update(row);
                _connection.InsertAll(fields);
                _connection.InsertAll(searchFields);
            }
            return(recipe);
        }
Пример #4
0
        public void Update <T>(T entity)
            where T : class
        {
            if (entity is EntityBase)
            {
                PrepareForUpdate(entity as EntityBase);
            }

            using (Connection.Lock())
            {
                Connection.Update(entity);
            }
        }
Пример #5
0
 public Task <int> UpdateAsync(object item)
 {
     if (item == null)
     {
         throw new ArgumentNullException("item");
     }
     return(Task.Factory.StartNew(() =>
     {
         SQLiteConnectionWithLock conn = GetConnection();
         using (conn.Lock())
         {
             return conn.Update(item);
         }
     }, CancellationToken.None, _taskCreationOptions, _taskScheduler ?? TaskScheduler.Default));
 }
Пример #6
0
 public Task <int> UpdateAsync(object item)
 {
     if (item == null)
     {
         throw new ArgumentNullException("item");
     }
     return(_taskFactory.StartNew(() =>
     {
         SQLiteConnectionWithLock conn = GetConnection();
         using (conn.Lock())
         {
             return conn.Update(item);
         }
     }));
 }
Пример #7
0
 public int Upsert(T entity)
 {
     //using (SQLiteConnection _dbManager = new SQLiteConnection(_baseUrl.GetDatabasePath(), WriteOnlyFlags))
     using (SQLiteConnectionWithLock _dbManager = new SQLiteConnectionWithLock(new SQLiteConnectionString(_baseUrl.GetDatabasePath(), false, null), SQLiteOpenFlags.ReadWrite | SQLiteOpenFlags.Create | SQLiteOpenFlags.FullMutex | SQLiteOpenFlags.SharedCache))
     {
         using (_dbManager.Lock())
         {
             try
             {
                 return(entity.Id == 0 ? _dbManager.Insert(entity) : _dbManager.Update(entity));
             }
             catch (Exception ex)
             {
                 Debug.WriteLine($"SQLiteError: {ex.Message}");
                 return(-1);
             }
         }
     }
 }
Пример #8
0
 public void UpsertAll(System.Collections.IEnumerable collection)
 {
     foreach (T item in collection)
     {
         if (item.Id == 0)
         {
             //using (SQLiteConnection _dbManager = new SQLiteConnection(_baseUrl.GetDatabasePath(), WriteOnlyFlags))
             using (SQLiteConnectionWithLock _dbManager = new SQLiteConnectionWithLock(new SQLiteConnectionString(_baseUrl.GetDatabasePath(), false, null), SQLiteOpenFlags.ReadWrite | SQLiteOpenFlags.Create | SQLiteOpenFlags.FullMutex | SQLiteOpenFlags.SharedCache))
             {
                 using (_dbManager.Lock())
                 {
                     try
                     {
                         _dbManager.Insert(item);
                     }
                     catch (Exception ex)
                     {
                         Debug.WriteLine($"SQLiteError: {ex.Message}");
                     }
                 }
             }
         }
         else
         {
             //using (SQLiteConnection _dbManager = new SQLiteConnection(_baseUrl.GetDatabasePath(), WriteOnlyFlags))
             using (SQLiteConnectionWithLock _dbManager = new SQLiteConnectionWithLock(new SQLiteConnectionString(_baseUrl.GetDatabasePath(), false, null), SQLiteOpenFlags.ReadWrite | SQLiteOpenFlags.Create | SQLiteOpenFlags.FullMutex | SQLiteOpenFlags.SharedCache))
             {
                 using (_dbManager.Lock())
                 {
                     try
                     {
                         _dbManager.Update(item);
                     }
                     catch (Exception ex)
                     {
                         Debug.WriteLine($"SQLiteError: {ex.Message}");
                     }
                 }
             }
         }
     }
 }