private Fetch ( |
||
objectType | ||
criteria | object | |
context | Csla.Server.DataPortalContext | |
isSync | bool | |
return | Task |
/// <summary> /// Get an existing business object. /// </summary> /// <param name="objectType">Type of business object to retrieve.</param> /// <param name="criteria">Criteria object describing business object.</param> /// <param name="context"> /// <see cref="Server.DataPortalContext" /> object passed to the server. /// </param> /// <param name="isSync">True if the client-side proxy should synchronously invoke the server.</param> public async Task <DataPortalResult> Fetch(Type objectType, object criteria, DataPortalContext context, bool isSync) { try { context.FactoryInfo = ObjectFactoryAttribute.GetObjectFactoryAttribute(objectType); if (context.FactoryInfo == null) { var dp = new SimpleDataPortal(); return(await dp.Fetch(objectType, criteria, context, isSync).ConfigureAwait(false)); } else { var dp = new FactoryDataPortal(); return(await dp.Fetch(objectType, criteria, context, isSync).ConfigureAwait(false)); } } catch (DataPortalException) { throw; } catch (Exception ex) { throw DataPortal.NewDataPortalException( "DataPortal.Fetch " + Resources.FailedOnServer, ex, null); } }
/// <summary> /// Get an existing business object. /// </summary> /// <param name="objectType">Type of business object to retrieve.</param> /// <param name="criteria">Criteria object describing business object.</param> /// <param name="context"> /// <see cref="Server.DataPortalContext" /> object passed to the server. /// </param> public DataPortalResult Fetch(Type objectType, object criteria, DataPortalContext context) { try { context.FactoryInfo = ObjectFactoryAttribute.GetObjectFactoryAttribute(objectType); if (context.FactoryInfo == null) { var dp = new SimpleDataPortal(); return(dp.Fetch(objectType, criteria, context)); } else { var dp = new FactoryDataPortal(); return(dp.Fetch(objectType, criteria, context)); } } catch (DataPortalException) { throw; } catch (Exception ex) { throw new DataPortalException( "DataPortal.Fetch " + Resources.FailedOnServer, ex, new DataPortalResult()); } }
/// <summary> /// Get an existing business object. /// </summary> /// <param name="objectType">Type of business object to retrieve.</param> /// <param name="criteria">Criteria object describing business object.</param> /// <param name="context"> /// <see cref="Server.DataPortalContext" /> object passed to the server. /// </param> /// <param name="isSync">True if the client-side proxy should synchronously invoke the server.</param> public async Task<DataPortalResult> Fetch(Type objectType, object criteria, DataPortalContext context, bool isSync) { try { context.FactoryInfo = ObjectFactoryAttribute.GetObjectFactoryAttribute(objectType); if (context.FactoryInfo == null) { var dp = new SimpleDataPortal(); return await dp.Fetch(objectType, criteria, context, isSync); } else { var dp = new FactoryDataPortal(); return await dp.Fetch(objectType, criteria, context, isSync); } } catch (DataPortalException) { throw; } catch (Exception ex) { throw DataPortal.NewDataPortalException( "DataPortal.Fetch " + Resources.FailedOnServer, ex, null); } }
/// <summary> /// Called by the client-side DataProtal to retrieve 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="objectType">Type of business object to retrieve.</param> /// <param name="criteria">Object-specific criteria.</param> /// <param name="context">Object containing context data from client.</param> /// <returns>A populated business object.</returns> public DataPortalResult Fetch(Type objectType, object criteria, DataPortalContext context) { DataPortalResult result; using (TransactionScope tr = new TransactionScope()) { SimpleDataPortal portal = new SimpleDataPortal(); result = portal.Fetch(objectType, criteria, context); tr.Complete(); } return(result); }
/// <summary> /// Get an existing business object. /// </summary> /// <param name="objectType">Type of business object to retrieve.</param> /// <param name="criteria">Criteria object describing business object.</param> /// <param name="context"> /// <see cref="Server.DataPortalContext" /> object passed to the server. /// </param> public DataPortalResult Fetch(Type objectType, object criteria, DataPortalContext context) { try { SetContext(context); DataPortalResult result; MethodInfo method = MethodCaller.GetMethod( objectType, "DataPortal_Fetch", criteria); IDataPortalServer portal; switch (TransactionalType(method)) { case TransactionalTypes.EnterpriseServices: portal = new ServicedDataPortal(); try { result = portal.Fetch(objectType, criteria, context); } finally { ((ServicedDataPortal)portal).Dispose(); } break; case TransactionalTypes.TransactionScope: portal = new TransactionalDataPortal(); result = portal.Fetch(objectType, criteria, context); break; default: portal = new SimpleDataPortal(); result = portal.Fetch(objectType, criteria, context); break; } return(result); } finally { ClearContext(context); } }
public DataPortalResult Fetch(Type objectType, object criteria, DataPortalContext context) { SimpleDataPortal portal = new SimpleDataPortal(); return(portal.Fetch(objectType, criteria, context)); }