public void Create(tblCatalog oCatalog) { try { using (var ctx = new CRUDSampleEntities()) { ctx.tblCatalogs.Add(oCatalog); ctx.SaveChanges(); } } catch (Exception ex) { throw ex; } }
public void Update(tblCatalog oCatalog) { try { using (var ctx = new CRUDSampleEntities()) { ctx.Entry(oCatalog).State = EntityState.Modified; ctx.SaveChanges(); } } catch (Exception ex) { throw ex; } }
public void Delete(int id) { try { using (var ctx = new CRUDSampleEntities()) { tblCatalog oCatalog = ctx.tblCatalogs.Where(c => c.Id == id).FirstOrDefault(); ctx.tblCatalogs.Remove(oCatalog); ctx.SaveChanges(); } } catch (Exception ex) { throw ex; } }
public void Delete(int id) { try { using (var ctx = new CRUDSampleEntities()) { tblStudent oStudent = ctx.tblStudents.Where(c => c.StudentId == id).FirstOrDefault(); ctx.tblStudents.Remove(oStudent); ctx.SaveChanges(); } } catch (Exception ex) { throw ex; } }
public void Create(tblStudent oStudent) { try { using (var ctx = new CRUDSampleEntities()) { oStudent.ModifiedDate = DateTime.Now; oStudent.CreateDate = DateTime.Now; oStudent.ModifiedDate = DateTime.Now; ctx.tblStudents.Add(oStudent); ctx.SaveChanges(); } } catch (Exception ex) { throw ex; } }
public void Update(tblStudent oStudent) { try { using (var ctx = new CRUDSampleEntities()) { ctx.tblContactDetails.Attach(oStudent.tblContactDetail); ctx.Entry(oStudent.tblContactDetail).State = EntityState.Modified; ctx.tblStudents.Attach(oStudent); ctx.Entry(oStudent).State = EntityState.Modified; ctx.SaveChanges(); } } catch (Exception ex) { throw ex; } }