public List <S> Select <S>(Expression <Func <T, S> > selector) { using (VETEntities entities = new VETEntities()) { return(entities.Set <T>().Select(selector).ToList()); } }
public int GetCount() { using (VETEntities entities = new VETEntities()) { return(entities.Set <T>().Count()); } }
public List <T> GetAll() { using (VETEntities entities = new VETEntities()) { return(entities.Set <T>().ToList()); } }
public void Delete(T entity) { using (VETEntities entities = new VETEntities()) { entities.Entry(entity).State = EntityState.Deleted; entities.SaveChanges(); } }
public void Update(T entity) { using (VETEntities entities = new VETEntities()) { entities.Entry(entity).State = EntityState.Modified; entities.SaveChanges(); } }
public List <Breeds> GetBreeds(int selectedValue) { using (VETEntities entities = new VETEntities()) { var query = from x in entities.Breeds where x.SpeciesID == selectedValue select x; return(query.ToList()); } }
public List <Prescription> GetRecord(int patientID) { using (VETEntities entities = new VETEntities()) { var query = from x in entities.Prescription where x.PatientID == patientID select x; List <Prescription> prescriptions = query.ToList(); return(prescriptions); } }
public List <Patient> Search(string phoneNum, string petName, int?speciesId) { using (VETEntities entities = new VETEntities()) { entities.Database.Log = x => Debug.WriteLine(x); var query = from x in entities.Patient select new { patient = x, CompanionName = x.Companion.Name, EmployeeName = x.Employee.Name, BreedsName = x.Breeds.Name, PhoneNumber = x.Companion.Phone, SpeciesId = x.Breeds.SpeciesID }; if (string.IsNullOrEmpty(phoneNum) == false) { query = query.Where(x => x.patient.Companion.Phone.Contains(phoneNum)); } if (string.IsNullOrEmpty(petName) == false) { query = query.Where(x => x.patient.Name.Contains(petName)); } if (speciesId != null) { query = query.Where(x => x.SpeciesId == speciesId); } var list = query.ToList(); foreach (var item in list) { item.patient.CompanionName = item.CompanionName; item.patient.EmployeeName = item.EmployeeName; item.patient.BreedsName = item.BreedsName; item.patient.PhoneNumber = item.PhoneNumber; item.patient.SpeciesID = item.SpeciesId; } return(list.ConvertAll(x => x.patient)); } }
public void Insert(T entity) { using (VETEntities entities = new VETEntities()) { entities.Set <T>().Add(entity); //entities.Entry(entity).State = EntityState.Added; try { entities.SaveChanges(); } catch (DbEntityValidationException ex) { MessageBox.Show("ValidatoinExceptionTest"); throw; } } }
public Patient SearchFromTreatementControl(string petName) { using (VETEntities entities = new VETEntities()) { var query = from x in entities.Patient select x; if (string.IsNullOrEmpty(petName) == false) { query = query.Where(x => x.Name.Contains(petName)); } Patient patient = new Patient(); foreach (var item in query) { patient = item; } return(patient); } }
public List <Employee> Search(string name, string num) { using (VETEntities entities = new VETEntities()) { entities.Database.Log = x => Debug.WriteLine(x); var query = from x in entities.Employee select x; if (string.IsNullOrEmpty(name) == false) { query = query.Where(x => x.Name.Contains(name)); } if (string.IsNullOrEmpty(num) == false) { query = query.Where(x => x.PhoneNum.Contains(num)); } return(query.ToList()); } }