コード例 #1
0
 public static AExpense.DataAccessLayer.Expense GetExpenseById(string databaseConnectionString, Guid expenseId)
 {
     using (var db = new ExpensesDataContext(databaseConnectionString))
     {
         return db.Expenses.SingleOrDefault(e => e.Id == expenseId);
     }
 }
コード例 #2
0
 public static void CreateExpense(string databaseConnectionString, Model.Expense expense)
 {
     using (var db = new ExpensesDataContext(databaseConnectionString))
     {
         db.Expenses.InsertOnSubmit(expense.ToEntity());
         db.SubmitChanges();
     }
 }
コード例 #3
0
 public static void BypassRepositoryAndDeleteExpense(string databaseConnectionString, Guid guid)
 {
     using (var db = new ExpensesDataContext(databaseConnectionString))
     {
         DataAccessLayer.Expense expense = db.Expenses.Where(e => e.Id == guid).ToList().FirstOrDefault();
         db.Expenses.DeleteOnSubmit(expense);
         db.SubmitChanges();
     }
 }
コード例 #4
0
 public static void DeleteDatabase(string connectionString)
 {
     using (var db = new ExpensesDataContext(connectionString))
     {
             if (db.DatabaseExists())
             {
                 db.DeleteDatabase();
             }
     }
 }
コード例 #5
0
        internal static void DeleteExpenseInDB(string TestDatabaseConnectionString, Guid testGuid)
        {
            using (var db = new ExpensesDataContext(TestDatabaseConnectionString))
            {
                var expDetails = db.ExpenseDetails.Where(e => e.ExpenseId == testGuid);
                db.ExpenseDetails.DeleteAllOnSubmit(expDetails);

                var exp = db.Expenses.Where(e => e.Id == testGuid);
                db.Expenses.DeleteAllOnSubmit(exp);
                db.SubmitChanges();
            }
        }