Exemple #1
0
 /// <summary>
 ///     Deletes all objects from the database that are specified in <see cref="args" />
 /// </summary>
 /// <typeparam name="T">The type of object we are removing from the database.</typeparam>
 /// <param name="args">The <see cref="IEnumerable{T}" /> collection of objects to delete.</param>
 /// <returns></returns>
 public static async Task DeleteAsync <T>(IEnumerable <T> args) where T : class, IKaguyaQueryable <T>
 {
     using (var db = new KaguyaDb())
     {
         foreach (T arg in args)
         {
             await db.DeleteAsync(arg);
         }
     }
 }
Exemple #2
0
        public static async Task DeleteAllAsync <T>() where T : class, IKaguyaQueryable <T>
        {
            using (var db = new KaguyaDb())
            {
                List <T> records = await db.GetTable <T>().ToListAsync();

                if (records.Count > 0)
                {
                    foreach (T record in records)
                    {
                        await db.DeleteAsync(record);
                    }
                }

                await ConsoleLogger.LogAsync($"Deleted all records of type {typeof(T)}", LogLvl.WARN);
            }
        }
Exemple #3
0
 /// <summary>
 ///     Deletes the <see cref="T" /> object from the database.
 /// </summary>
 /// <typeparam name="T">The type of object we are removing from the database.</typeparam>
 /// <param name="arg">The exact object that we are deleting from the database.</param>
 /// <returns></returns>
 public static async Task DeleteAsync <T>(T arg) where T : class, IKaguyaQueryable <T>
 {
     using (var db = new KaguyaDb())
         await db.DeleteAsync(arg);
 }