public void UpdateAll <T>(IEnumerable <T> entities) where T : class
        {
            var enumerable = entities as T[] ?? entities.ToArray();

            var utcNow = DateTime.UtcNow;

            foreach (var entity in enumerable.Where(x => x is EntityBase).Cast <EntityBase>())
            {
                PrepareForUpdate(entity, utcNow);
            }

            using (Connection.Lock())
            {
                Connection.UpdateAll(enumerable);
            }
        }
Esempio n. 2
0
 public int UpdateAll(System.Collections.IEnumerable collection)
 {
     //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(_dbManager.UpdateAll(collection));
             }
             catch (Exception ex)
             {
                 Debug.WriteLine($"SQLiteError: {ex.Message}");
                 return(-1);
             }
         }
     }
 }