9using System.Threading.Tasks;
24 public object Create(Type objectType)
28 return Create(objectType,
false).Result;
30 catch (AggregateException ex)
32 throw ex.InnerException;
43 public object Create(Type objectType, params
object[] parameters)
47 return Create(objectType,
true, parameters).Result;
49 catch (AggregateException ex)
51 throw ex.InnerException;
60 return (T) await
Create(typeof(T),
false).ConfigureAwait(
false);
71 return (T)await
Create(typeof(T),
true, parameters).ConfigureAwait(
false);
74 private async Task<object>
Create(Type objectType,
bool hasParameters, params
object[] parameters)
76 DataPortalTarget obj =
null;
80 obj =
new DataPortalTarget(ApplicationContext.DataPortalActivator.CreateInstance(objectType));
81 ApplicationContext.DataPortalActivator.InitializeInstance(obj.Instance);
82 obj.Child_OnDataPortalInvoke(eventArgs);
85 await obj.CreateChildAsync(parameters).ConfigureAwait(
false);
86 obj.OnDataPortalInvokeComplete(eventArgs);
95 obj.Child_OnDataPortalException(eventArgs, ex);
101 object outval =
null;
102 if (obj !=
null) outval = obj.Instance;
104 "ChildDataPortal.Create " + Properties.Resources.FailedOnServer, ex, outval);
108 object reference =
null;
110 reference = obj.Instance;
111 ApplicationContext.DataPortalActivator.FinalizeInstance(reference);
119 public object Fetch(Type objectType)
123 return Fetch(objectType,
false,
null).Result;
125 catch (AggregateException ex)
127 throw ex.InnerException;
138 public object Fetch(Type objectType, params
object[] parameters)
142 return Fetch(objectType,
true, parameters).Result;
144 catch (AggregateException ex)
146 throw ex.InnerException;
155 return (T)await
Fetch(typeof(T),
false).ConfigureAwait(
false);
166 return (T)await
Fetch(typeof(T),
true, parameters).ConfigureAwait(
false);
169 private async Task<object>
Fetch(Type objectType,
bool hasParameters, params
object[] parameters)
171 DataPortalTarget obj =
null;
176 obj =
new DataPortalTarget(ApplicationContext.DataPortalActivator.CreateInstance(objectType));
177 ApplicationContext.DataPortalActivator.InitializeInstance(obj.Instance);
179 obj.Child_OnDataPortalInvoke(eventArgs);
182 await obj.FetchChildAsync(parameters).ConfigureAwait(
false);
183 obj.Child_OnDataPortalInvokeComplete(eventArgs);
191 obj.Child_OnDataPortalException(eventArgs, ex);
197 object outval =
null;
198 if (obj !=
null) outval = obj.Instance;
200 "ChildDataPortal.Fetch " + Properties.Resources.FailedOnServer, ex, outval);
204 ApplicationContext.DataPortalActivator.FinalizeInstance(obj.Instance);
216 Update(obj,
false,
false,
null).Wait();
218 catch (AggregateException ex)
220 throw ex.InnerException;
231 public void Update(
object obj, params
object[] parameters)
235 Update(obj,
true,
false, parameters).Wait();
237 catch (AggregateException ex)
239 throw ex.InnerException;
249 await
Update(obj,
false,
false,
null).ConfigureAwait(
false);
259 public async Task
UpdateAsync(
object obj, params
object[] parameters)
261 await
Update(obj,
true,
false, parameters).ConfigureAwait(
false);
270 Update(obj,
false,
true,
null).Wait();
280 public void UpdateAll(
object obj, params
object[] parameters)
282 Update(obj,
true,
true, parameters).Wait();
291 await
Update(obj,
false,
true,
null).ConfigureAwait(
false);
303 await
Update(obj,
true,
true, parameters).ConfigureAwait(
false);
306 private async Task
Update(
object obj,
bool hasParameters,
bool bypassIsDirtyTest, params
object[] parameters)
311 if (obj is Core.BusinessBase busObj && busObj.IsDirty ==
false && bypassIsDirtyTest ==
false)
318 Type objectType = obj.GetType();
319 DataPortalTarget lb =
new DataPortalTarget(obj);
320 ApplicationContext.DataPortalActivator.InitializeInstance(lb.Instance);
324 lb.Child_OnDataPortalInvoke(
326 await lb.UpdateChildAsync(parameters).ConfigureAwait(
false);
327 lb.Child_OnDataPortalInvokeComplete(
335 lb.Child_OnDataPortalException(
336 new DataPortalEventArgs(
null, objectType, obj, operation), ex);
343 "ChildDataPortal.Update " + Properties.Resources.FailedOnServer, ex, obj);
347 ApplicationContext.DataPortalActivator.FinalizeInstance(lb.Instance);
Provides information about the DataPortal call.
This exception is returned for any errors occurring during the server-side DataPortal invocation.
Invoke data portal methods on child objects.
void Update(object obj, params object[] parameters)
Update a business object.
async Task UpdateAllAsync(object obj, params object[] parameters)
Update a business object.
void Update(object obj)
Update a business object.
async Task UpdateAsync(object obj, params object[] parameters)
Update a business object.
async Task< T > FetchAsync< T >()
Get an existing business object.
object Create(Type objectType)
Create a new business object.
object Fetch(Type objectType)
Get an existing business object.
async Task UpdateAllAsync(object obj)
Update a business object.
void UpdateAll(object obj, params object[] parameters)
Update a business object.
object Create(Type objectType, params object[] parameters)
Create a new business object.
void UpdateAll(object obj)
Update a business object.
object Fetch(Type objectType, params object[] parameters)
Get an existing business object.
async Task< T > CreateAsync< T >()
Create a new business object.
async Task UpdateAsync(object obj)
Update a business object.
DataPortalOperations
List of data portal operations.