コード例 #1
0
 public Contact GetContactById(int id)
 {
     using (ContactDBEntities entities = new ContactDBEntities())
     {
         return(entities.Contacts.Where(x => x.ID == id && x.Status).FirstOrDefault());
     }
 }
コード例 #2
0
 public List <Contact> GetContacts()
 {
     using (ContactDBEntities entities = new ContactDBEntities())
     {
         return(entities.Contacts.Where(x => x.Status).ToList());
     }
 }
コード例 #3
0
 public bool SaveContactInfo(Contact contact)
 {
     using (ContactDBEntities entities = new ContactDBEntities())
     {
         try
         {
             entities.Contacts.Add(contact);
             entities.SaveChanges();
             return(true);
         }
         catch (Exception ex)
         {
             return(false);
         }
     }
 }