예제 #1
0
 public Account LoadAccount(string accountNumber)
 {
     using (var context = new AccountDBEntities())
     {
         return(context.Accounts.SingleOrDefault(a => a.AccountNumber == accountNumber));
     }
 }
예제 #2
0
 public void Delete(string accountNumber)
 {
     using (var context = new AccountDBEntities())
     {
         context.Accounts.Remove(LoadAccount(accountNumber));
     }
 }
예제 #3
0
        public void SaveAccount(Account account)
        {
            AccountDBEntities entities = new AccountDBEntities();

            entities.Accounts.Attach(account);
            entities.Entry(account).State = EntityState.Modified;
            entities.SaveChanges();
        }
예제 #4
0
 public void Add(Account account)
 {
     using (var context = new AccountDBEntities())
     {
         context.Accounts.Add(account);
         context.SaveChanges();
     }
 }
예제 #5
0
        public List <Account> List()
        {
            List <Account> accounts = new List <Account>();

            using (var context = new AccountDBEntities())
            {
                foreach (var account in context.Accounts)
                {
                    accounts.Add(account);
                }
            }
            return(accounts);
        }