コード例 #1
0
 private static void DumpDatabaseData()
 {
     using (var context = new VehicleStoreContext())
     {
         var branchesWithRevenues = context.Branches.Include(b => b.Revenues);
         foreach (var branch in branchesWithRevenues)
         {
             Console.WriteLine(branch);
         }
     }
 }
コード例 #2
0
 private static void SaveDataIntoDatabase(IEnumerable <BranchEntity> data)
 {
     using (var context = new VehicleStoreContext())
     {
         foreach (var branch in data)
         {
             context.Branches.Add(branch);
         }
         context.SaveChanges();
     }
 }
コード例 #3
0
        private static void ClearDatabase()
        {
            using (var context = new VehicleStoreContext())
            {
                var deleteRevenuesSql = $"DELETE FROM {MonthlyRevenueEntity.TableName}";
                context.Database.ExecuteSqlCommand(deleteRevenuesSql);

                var deleteBranchesSql = $"DELETE FROM {BranchEntity.TableName}";
                context.Database.ExecuteSqlCommand(deleteBranchesSql);
            }
        }