コード例 #1
0
    //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);
    }
コード例 #2
0
 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);
 }