//Delete an existing entity from the model public void Delete <T>(T entity) where T : class { //var table = _service.GetTable<T>(); //table.DeleteOnSubmit(_entity); object originalItem; EntityKey key = _service.CreateEntityKey(typeof(T).Name, entity); if (_service.TryGetObjectByKey(key, out originalItem)) { _service.DeleteObject(originalItem); } //_service.CreateObjectSet<T>().DeleteObject(_entity); }
public bool SaveChanges(System.Data.Objects.ObjectContext dataContext) { if (dataContext != null && this.TowarGuid != Guid.Empty) { if (this.EntityState == System.Data.EntityState.Detached) { dataContext.AddObject("Magazyn_StanyMagazynowe", this); } dataContext.SaveChanges(); dataContext.Refresh(System.Data.Objects.RefreshMode.StoreWins, this); return(true); } if (this.EntityState == System.Data.EntityState.Added) { dataContext.DeleteObject(this); } return(false); }