9using System.Threading.Tasks;
10using System.Transactions;
30 _transactionalAttribute = transactionalAttribute;
51 public async Task<DataPortalResult>
Create(
58 result = await portal.Create(objectType, criteria, context, isSync).ConfigureAwait(
false);
66 return new TransactionScope(TransactionScopeOption.Required, GetTransactionOptions(), _transactionalAttribute.AsyncFlowOption);
69 private TransactionOptions GetTransactionOptions()
71 var option =
new TransactionOptions
73 IsolationLevel = GetIsolationLevel(_transactionalAttribute.TransactionIsolationLevel),
74 Timeout = TimeSpan.FromSeconds(_transactionalAttribute.TimeoutInSeconds)
81 switch (transactionIsolationLevel)
84 return IsolationLevel.Unspecified;
86 return IsolationLevel.Serializable;
88 return IsolationLevel.RepeatableRead;
90 return IsolationLevel.ReadCommitted;
92 return IsolationLevel.ReadUncommitted;
94 return IsolationLevel.Unspecified;
120 result = await portal.Fetch(objectType, criteria, context, isSync).ConfigureAwait(
false);
147 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.
async Task< DataPortalResult > Fetch(Type objectType, object criteria, DataPortalContext context, bool isSync)
Called by the client-side DataProtal to retrieve an object.
TransactionalDataPortal(TransactionalAttribute transactionalAttribute)
Initializes a new instance of the TransactionalDataPortal class.
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