示例#1
0
 public Customer LoadCustomer(int ID)
 {
     using (var context = new SGBankEntities())
     {
         return(context.Customers.SingleOrDefault(c => c.ID == ID));
     }
 }
示例#2
0
 public Account LoadAccount(string AccountNumber)
 {
     using (var context = new SGBankEntities())
     {
         return(context.Accounts.SingleOrDefault(
                    a => a.AccountNumber == AccountNumber));
     }
 }
示例#3
0
        public void SaveAccount(Account account)
        {
            using (var context = new SGBankEntities())
            {
                context.Accounts.Attach(account);

                context.Entry(account).State = EntityState.Modified;

                context.SaveChanges();
            }
        }
示例#4
0
        public void DeleteAccount(string accountNumber)
        {
            using (var context = new SGBankEntities())
            {
                Account accountToDelete = context.Accounts.SingleOrDefault(
                    a => a.AccountNumber == accountNumber);

                context.Accounts.Attach(accountToDelete);

                context.Accounts.Remove(accountToDelete);

                context.SaveChanges();
            }
        }