9using System.Threading.Tasks;
30 [System.Diagnostics.CodeAnalysis.SuppressMessage(
"Microsoft.Globalization",
"CA1303:DoNotPassLiteralsAsLocalizedParameters", MessageId =
"Csla.Server.DataPortalException.#ctor(System.String,System.Exception,Csla.Server.DataPortalResult)")]
31 [System.Diagnostics.CodeAnalysis.SuppressMessage(
"Microsoft.Design",
"CA1031:DoNotCatchGeneralExceptionTypes")]
32 public async Task<DataPortalResult>
Create(
35 DataPortalTarget obj =
null;
39 obj =
new DataPortalTarget(ApplicationContext.DataPortalActivator.CreateInstance(objectType));
40 ApplicationContext.DataPortalActivator.InitializeInstance(obj.Instance);
41 obj.OnDataPortalInvoke(eventArgs);
43 await obj.CreateAsync(criteria, isSync);
45 obj.OnDataPortalInvokeComplete(eventArgs);
53 obj.OnDataPortalException(eventArgs, ex);
60 if (obj !=
null) outval = obj.Instance;
68 object reference =
null;
70 reference = obj.Instance;
71 ApplicationContext.DataPortalActivator.FinalizeInstance(reference);
84 [System.Diagnostics.CodeAnalysis.SuppressMessage(
"Microsoft.Globalization",
"CA1303:DoNotPassLiteralsAsLocalizedParameters", MessageId =
"Csla.Server.DataPortalException.#ctor(System.String,System.Exception,Csla.Server.DataPortalResult)")]
85 [System.Diagnostics.CodeAnalysis.SuppressMessage(
"Microsoft.Design",
"CA1031:DoNotCatchGeneralExceptionTypes")]
88 DataPortalTarget obj =
null;
92 obj =
new DataPortalTarget(ApplicationContext.DataPortalActivator.CreateInstance(objectType));
93 ApplicationContext.DataPortalActivator.InitializeInstance(obj.Instance);
94 obj.OnDataPortalInvoke(eventArgs);
96 await obj.FetchAsync(criteria, isSync);
98 obj.OnDataPortalInvokeComplete(eventArgs);
106 obj.OnDataPortalException(eventArgs, ex);
112 object outval =
null;
113 if (obj !=
null) outval = obj.Instance;
121 object reference =
null;
123 reference = obj.Instance;
124 ApplicationContext.DataPortalActivator.FinalizeInstance(reference);
136 [System.Diagnostics.CodeAnalysis.SuppressMessage(
"Microsoft.Performance",
"CA1800:DoNotCastUnnecessarily")]
137 [System.Diagnostics.CodeAnalysis.SuppressMessage(
"Microsoft.Globalization",
"CA1303:DoNotPassLiteralsAsLocalizedParameters", MessageId =
"Csla.Server.DataPortalException.#ctor(System.String,System.Exception,Csla.Server.DataPortalResult)")]
141 Type objectType = obj.GetType();
142 var lb =
new DataPortalTarget(obj);
143 if (lb.Instance is Core.ICommandObject)
144 return await Execute(lb, context, isSync);
149 ApplicationContext.DataPortalActivator.InitializeInstance(lb.Instance);
150 lb.OnDataPortalInvoke(eventArgs);
151 await lb.UpdateAsync(isSync);
153 lb.OnDataPortalInvokeComplete(eventArgs);
160 lb.OnDataPortalException(eventArgs, ex);
173 object reference =
null;
175 reference = lb.Instance;
176 ApplicationContext.DataPortalActivator.FinalizeInstance(reference);
180 private async Task<DataPortalResult> Execute(DataPortalTarget obj,
DataPortalContext context,
bool isSync)
183 Type objectType = obj.Instance.GetType();
187 ApplicationContext.DataPortalActivator.InitializeInstance(obj.Instance);
188 obj.OnDataPortalInvoke(eventArgs);
189 await obj.ExecuteAsync(isSync);
191 obj.OnDataPortalInvokeComplete(eventArgs);
198 obj.OnDataPortalException(eventArgs, ex);
204 object reference =
null;
205 reference = obj.Instance ?? obj;
206 throw DataPortal.NewDataPortalException(
208 new DataPortalExceptionHandler().InspectException(reference.GetType(), reference,
null,
"DataPortal.Execute", ex),
213 object reference =
null;
215 reference = obj.Instance;
216 ApplicationContext.DataPortalActivator.FinalizeInstance(reference);
228 [System.Diagnostics.CodeAnalysis.SuppressMessage(
"Microsoft.Globalization",
"CA1303:DoNotPassLiteralsAsLocalizedParameters", MessageId =
"Csla.Server.DataPortalException.#ctor(System.String,System.Exception,Csla.Server.DataPortalResult)")]
231 DataPortalTarget obj =
null;
235 obj =
new DataPortalTarget(ApplicationContext.DataPortalActivator.CreateInstance(objectType));
236 ApplicationContext.DataPortalActivator.InitializeInstance(obj.Instance);
237 obj.OnDataPortalInvoke(eventArgs);
238 await obj.DeleteAsync(criteria, isSync);
240 obj.OnDataPortalInvokeComplete(eventArgs);
247 obj.OnDataPortalException(eventArgs, ex);
260 object reference =
null;
262 reference = obj.Instance;
263 ApplicationContext.DataPortalActivator.FinalizeInstance(reference);
Provides information about the DataPortal call.
A strongly-typed resource class, for looking up localized strings, etc.
static string FailedOnServer
Looks up a localized string similar to failed on the server.
Provides consistent context information between the client and server DataPortal objects.
This class provides a hoook for developers to add custom error handling in the DataPortal.
Implements the server-side DataPortal message router as discussed in Chapter 4.
Returns data from the server-side DataPortal to the client-side DataPortal.
Implements the server-side DataPortal as discussed in Chapter 4.
async Task< DataPortalResult > Fetch(Type objectType, object criteria, DataPortalContext context, bool isSync)
Get an existing business object.
async Task< DataPortalResult > Create(Type objectType, object criteria, DataPortalContext context, bool isSync)
Create a new business object.
async Task< DataPortalResult > Update(object obj, DataPortalContext context, bool isSync)
Update a business object.
async Task< DataPortalResult > Delete(Type objectType, object criteria, DataPortalContext context, bool isSync)
Delete a business object.
Interface implemented by server-side data portal components.
DataPortalOperations
List of data portal operations.