9using System.Threading.Tasks;
10using System.Transactions;
32 _portal = dataPortalBroker;
33 _transactionalAttribute = transactionalAttribute;
55 public async Task<DataPortalResult>
Create(
61 result = await _portal.Create(objectType, criteria, context, isSync).ConfigureAwait(
false);
69 return new TransactionScope(TransactionScopeOption.Required, GetTransactionOptions(), _transactionalAttribute.AsyncFlowOption);
72 private TransactionOptions GetTransactionOptions()
74 var option =
new TransactionOptions
76 IsolationLevel = GetIsolationLevel(_transactionalAttribute.TransactionIsolationLevel),
77 Timeout = TimeSpan.FromSeconds(_transactionalAttribute.TimeoutInSeconds)
84 switch (transactionIsolationLevel)
87 return IsolationLevel.Unspecified;
89 return IsolationLevel.Serializable;
91 return IsolationLevel.RepeatableRead;
93 return IsolationLevel.ReadCommitted;
95 return IsolationLevel.ReadUncommitted;
97 return IsolationLevel.Unspecified;
122 result = await _portal.Fetch(objectType, criteria, context, isSync).ConfigureAwait(
false);
148 result = await _portal.Update(obj, context, isSync).ConfigureAwait(
false);
174 result = await _portal.Delete(objectType, criteria, context, isSync).ConfigureAwait(
false);
Allows the Data Portal call to be intercepted by a custom IDataPortalServer implementation.
Provides consistent context information between the client and server DataPortal objects.
Returns data from the server-side DataPortal to the client-side DataPortal.
Implements the server-side Serviced DataPortal described in Chapter 4.
async Task< DataPortalResult > Delete(Type objectType, object criteria, DataPortalContext context, bool isSync)
Called by the client-side DataPortal to delete an object.
TransactionalDataPortal(DataPortalBroker dataPortalBroker, TransactionalAttribute transactionalAttribute)
Initializes a new instance of the TransactionalDataPortal class.
async Task< DataPortalResult > Fetch(Type objectType, object criteria, DataPortalContext context, bool isSync)
Called by the client-side DataProtal to retrieve an object.
async Task< DataPortalResult > Create(Type objectType, object criteria, DataPortalContext context, bool isSync)
Wraps a Create call in a TransactionScope
async Task< DataPortalResult > Update(object obj, DataPortalContext context, bool isSync)
Called by the client-side DataPortal to update an object.
Marks a DataPortal_XYZ method to run within the specified transactional context.
Interface implemented by server-side data portal components.
@ TransactionScope
Causes the server-side DataPortal to use System.Transactions TransactionScope style transactions.
TransactionIsolationLevel
Specifies an isolation level for transactions controlled by TransactionalAttribute