/// <summary> /// Called by the client-side DataPortal to delete an object. /// </summary> /// <remarks> /// This method delegates to /// <see cref="SimpleDataPortal">SimpleDataPortal</see> /// but wraps that call within a /// <see cref="TransactionScope">TransactionScope</see> /// to provide transactional support via /// System.Transactions. /// </remarks> /// <param name="criteria">Object-specific criteria.</param> /// <param name="context">Context data from the client.</param> public DataPortalResult Delete(object criteria, DataPortalContext context) { DataPortalResult result; using (TransactionScope tr = new TransactionScope()) { SimpleDataPortal portal = new SimpleDataPortal(); result = portal.Delete(criteria, context); tr.Complete(); } return result; }
public DataPortalResult Delete(object criteria, DataPortalContext context) { SimpleDataPortal portal = new SimpleDataPortal(); return portal.Delete(criteria, context); }
/// <summary> /// Delete a business object. /// </summary> /// <param name="criteria">Criteria object describing business object.</param> /// <param name="context"> /// <see cref="Server.DataPortalContext" /> object passed to the server. /// </param> public DataPortalResult Delete(object criteria, DataPortalContext context) { try { SetContext(context); DataPortalResult result; MethodInfo method = MethodCaller.GetMethod( MethodCaller.GetObjectType(criteria), "DataPortal_Delete", criteria); IDataPortalServer portal; switch (TransactionalType(method)) { case TransactionalTypes.EnterpriseServices: portal = new ServicedDataPortal(); try { result = portal.Delete(criteria, context); } finally { ((ServicedDataPortal)portal).Dispose(); } break; case TransactionalTypes.TransactionScope: portal = new TransactionalDataPortal(); result = portal.Delete(criteria, context); break; default: portal = new SimpleDataPortal(); result = portal.Delete(criteria, context); break; } return result; } catch (DataPortalException ex) { Exception tmp = ex; throw; } catch (Exception ex) { throw new DataPortalException( "DataPortal.Delete " + "Failed on server", ex, new DataPortalResult()); } finally { ClearContext(context); } }