public void Add(PageObjectRoleDTO DTO) { using (var container = new InventoryContainer()) { PageObjectRole gur = new PageObjectRole(); container.PageObjectRoles.AddObject((PageObjectRole)DTOMapper.DTOObjectConverter(DTO, gur)); container.SaveChanges(); } }
// delete data public void Delete_Data(int pageobjectid, int roleid) { using (var Container = new InventoryContainer()) { var delete = new PageObjectRole(); delete = Container.PageObjectRoles.FirstOrDefault(o => o.PageObjectId.Equals(pageobjectid) && o.RoleId.Equals(roleid)); Container.PageObjectRoles.DeleteObject(delete); Container.SaveChanges(); } //CustomerDataContext ctx = new CustomerDataContext("connection string"); //Customer cust = ctx.Customers.Where(c = c.CustomerID == "ALFKI").Single(); //ctx.Customers.DeleteOnSubmit(cust); //ctx.SubmitChanges(); }
public void Edit(PageObjectRoleDTO EduDTO) { using (var container = new InventoryContainer()) { var Comp = new PageObjectRole(); Comp = container.PageObjectRoles.FirstOrDefault(o => o.PageObjAccId.Equals(EduDTO.PageObjAccId)); Comp.PageObjAccId = EduDTO.PageObjAccId; Comp.RoleId = EduDTO.RoleId; Comp.PageObjectId = EduDTO.PageObjectId; Comp.UpdateBy = EduDTO.UpdateBy; Comp.UpdateDate = EduDTO.UpdateDate; Comp = (PageObjectRole)DTOMapper.DTOObjectConverter(EduDTO, Comp); container.SaveChanges(); } }