public void Create(tblCatalogType oCatalogType) { try { using (var ctx = new CRUDSampleEntities()) { ctx.tblCatalogTypes.Add(oCatalogType); ctx.SaveChanges(); } } catch (Exception ex) { throw ex; } }
public void Delete(int id) { try { using (var ctx = new CRUDSampleEntities()) { tblCatalogType oCatalogType = ctx.tblCatalogTypes.Where(c => c.TypeId == id).FirstOrDefault(); ctx.tblCatalogTypes.Remove(oCatalogType); 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(tblCatalogType oCatalogType) { try { using (var ctx = new CRUDSampleEntities()) { ctx.Entry(oCatalogType).State = EntityState.Modified; 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; } }