protected override void UpdateDataObject(object dataContext, object table, object oldDataObject, object newDataObject) { var dataServiceContext = (DataServiceContext)dataContext; var idataServiceContext = dataContext as IDataServiceContext; string etag = null; if (this._etagMap != null && this._etagMap.TryGetValue(DataServiceUtilities.BuildCompositeKey(oldDataObject), out etag)) { if (idataServiceContext != null) { idataServiceContext.AttachTo(TableName, newDataObject, etag); } else { dataServiceContext.AttachTo(TableName, newDataObject, etag); } } else { if (idataServiceContext != null) { idataServiceContext.AttachTo(TableName, newDataObject); } else { dataServiceContext.AttachTo(TableName, newDataObject); } } ProcessForeignKeys(dataServiceContext, newDataObject, _values); dataServiceContext.UpdateObject(newDataObject); DataServiceResponse dataServiceResponse = dataServiceContext.SaveChanges(); }
protected override void DeleteDataObject(object dataContext, object table, object oldDataObject) { var dataServiceContext = (DataServiceContext)dataContext; var idataServiceContext = dataContext as IDataServiceContext; string etag = null; if (this._etagMap != null && this._etagMap.TryGetValue(DataServiceUtilities.BuildCompositeKey(oldDataObject), out etag)) { if (idataServiceContext != null) { idataServiceContext.AttachTo(TableName, oldDataObject, etag); } else { dataServiceContext.AttachTo(TableName, oldDataObject, etag); } } else { if (idataServiceContext != null) { idataServiceContext.AttachTo(TableName, oldDataObject); } else { dataServiceContext.AttachTo(TableName, oldDataObject); } } dataServiceContext.DeleteObject(oldDataObject); dataServiceContext.SaveChanges(); }
protected override object SaveViewState() { var myState = new Pair(); myState.First = base.SaveViewState(); if (_dataServiceContext != null) { myState.Second = _dataServiceContext.Entities.Where(ed => !String.IsNullOrEmpty(ed.ETag)).ToDictionary( ed => DataServiceUtilities.BuildCompositeKey(ed.Entity), ed => ed.ETag); } return(myState); }