CSLA.NET 6.0.0
CSLA .NET is a software development framework that helps you build a reusable, maintainable object-oriented business layer for your app.
DataPortalT.cs
Go to the documentation of this file.
1//-----------------------------------------------------------------------
2// <copyright file="DataPortalT.cs" company="Marimer LLC">
3// Copyright (c) Marimer LLC. All rights reserved.
4// Website: https://cslanet.com
5// </copyright>
6// <summary>Client side data portal used for making asynchronous</summary>
7//-----------------------------------------------------------------------
8using System;
9using System.Globalization;
10using System.Linq;
11using System.Threading.Tasks;
12using Csla.Properties;
13
14namespace Csla
15{
24 {
30 public DataPortal(ApplicationContext applicationContext, DataPortalClient.IDataPortalProxy proxy)
31 {
32 ApplicationContext = applicationContext;
33 DataPortalProxy = proxy;
34 }
35
39 private ApplicationContext ApplicationContext { get; set; }
40 private DataPortalClient.IDataPortalProxy DataPortalProxy { get; set; }
41
42 private class DataPortalAsyncRequest
43 {
44 private ApplicationContext ApplicationContext { get; set; }
45
46 public object Argument { get; set; }
47 public System.Security.Principal.IPrincipal Principal { get; set; }
48 public Csla.Core.ContextDictionary ClientContext { get; set; }
49 public object UserState { get; set; }
50 // passes CurrentCulture and CurrentUICulture to the async thread
51 public CultureInfo CurrentCulture;
52 public CultureInfo CurrentUICulture;
53
54 public DataPortalAsyncRequest(ApplicationContext applicationContext, object argument, object userState)
55 {
56 ApplicationContext = applicationContext;
57 this.Argument = argument;
58 this.Principal = ApplicationContext.User;
59 this.ClientContext = ApplicationContext.ClientContext;
60 this.UserState = userState;
61 this.CurrentCulture = System.Globalization.CultureInfo.CurrentCulture;
62 this.CurrentUICulture = System.Globalization.CultureInfo.CurrentUICulture;
63 }
64 }
65
66 private class DataPortalAsyncResult
67 {
68 public T Result { get; set; }
69 public object UserState { get; set; }
70 public Exception Error { get; set; }
71
72 public DataPortalAsyncResult(T result, Exception error, object userState)
73 {
74 this.Result = result;
75 this.UserState = userState;
76 this.Error = error;
77 }
78 }
79
80 private Reflection.ServiceProviderMethodCaller serviceProviderMethodCaller;
81 private Reflection.ServiceProviderMethodCaller ServiceProviderMethodCaller
82 {
83 get
84 {
85 if (serviceProviderMethodCaller == null)
86 serviceProviderMethodCaller = (Reflection.ServiceProviderMethodCaller)ApplicationContext.CreateInstanceDI(typeof(Reflection.ServiceProviderMethodCaller));
87 return serviceProviderMethodCaller;
88 }
89 }
90
91 private async Task<object> DoCreateAsync(Type objectType, object criteria, bool isSync)
92 {
93 Server.DataPortalResult result = null;
94 Server.DataPortalContext dpContext = null;
95 try
96 {
97 if (!Csla.Rules.BusinessRules.HasPermission(ApplicationContext, Rules.AuthorizationActions.CreateObject, objectType, Server.DataPortal.GetCriteriaArray(criteria)))
98 throw new Csla.Security.SecurityException(string.Format(
100 "create",
101 objectType.Name));
102 Reflection.ServiceProviderMethodInfo method;
103 if (criteria is Server.EmptyCriteria)
104 method = ServiceProviderMethodCaller.FindDataPortalMethod<CreateAttribute>(objectType, null, false);
105 else
106 method = ServiceProviderMethodCaller.FindDataPortalMethod<CreateAttribute>(objectType, Server.DataPortal.GetCriteriaArray(criteria), false);
107 var proxy = GetDataPortalProxy(method);
108
109 dpContext =
110 new Csla.Server.DataPortalContext(ApplicationContext, GetPrincipal(), proxy.IsServerRemote);
111
112 try
113 {
114 result = await proxy.Create(objectType, criteria, dpContext, isSync);
115 }
116 catch (AggregateException ex)
117 {
118 if (ex.InnerExceptions.Count > 0)
119 {
120 if (ex.InnerExceptions[0] is Server.DataPortalException dpe)
121 HandleCreateDataPortalException(dpe, isSync, proxy);
122 }
123 throw new DataPortalException(
124 string.Format("DataPortal.Create {0}", Resources.Failed),
125 ex, null);
126 }
127 catch (Server.DataPortalException ex)
128 {
129 HandleCreateDataPortalException(ex, isSync, proxy);
130 }
131 }
132 catch
133 {
134 throw;
135 }
136 return result.ReturnObject;
137 }
138
139 private void HandleCreateDataPortalException(Server.DataPortalException ex, bool isSync, Csla.DataPortalClient.IDataPortalProxy proxy)
140 {
141 HandleDataPortalException("Create", ex, isSync, proxy);
142 }
143
151 public T Create(params object[] criteria)
152 {
153 return (T)Create(typeof(T), Server.DataPortal.GetCriteriaFromArray(criteria));
154 }
155
162
163 private object Create(Type objectType, object criteria)
164 {
165 try
166 {
167 return DoCreateAsync(objectType, criteria, true).Result;
168 }
169 catch (AggregateException ex)
170 {
171 if (ex.InnerExceptions.Count > 0)
172 throw ex.InnerExceptions[0];
173 else
174 throw;
175 }
176 }
177
184 public async Task<T> CreateAsync(params object[] criteria)
185 {
186 return (T)await DoCreateAsync(typeof(T), Server.DataPortal.GetCriteriaFromArray(criteria), false);
187 }
188
189 private async Task<object> DoFetchAsync(Type objectType, object criteria, bool isSync)
190 {
191 Server.DataPortalResult result = null;
192 Server.DataPortalContext dpContext = null;
193 try
194 {
195 if (!Csla.Rules.BusinessRules.HasPermission(ApplicationContext, Rules.AuthorizationActions.GetObject, objectType, Server.DataPortal.GetCriteriaArray(criteria)))
196 throw new Csla.Security.SecurityException(string.Format(
198 "get",
199 objectType.Name));
200
201 var method = ServiceProviderMethodCaller.FindDataPortalMethod<FetchAttribute>(objectType, Server.DataPortal.GetCriteriaArray(criteria), false);
202 var proxy = GetDataPortalProxy(method);
203
204 dpContext =
205 new Csla.Server.DataPortalContext(ApplicationContext, GetPrincipal(), proxy.IsServerRemote);
206
207 try
208 {
209 result = await proxy.Fetch(objectType, criteria, dpContext, isSync);
210 }
211 catch (AggregateException ex)
212 {
213 if (ex.InnerExceptions.Count > 0)
214 {
215 var dpe = ex.InnerExceptions[0] as Server.DataPortalException;
216 if (dpe != null)
217 HandleFetchDataPortalException(dpe, isSync, proxy);
218 }
219 throw new DataPortalException(
220 string.Format("DataPortal.Fetch {0}", Resources.Failed),
221 ex, null);
222 }
223 catch (Server.DataPortalException ex)
224 {
225 HandleFetchDataPortalException(ex, isSync, proxy);
226 }
227 }
228 catch
229 {
230 throw;
231 }
232 return result.ReturnObject;
233 }
234
235 private void HandleFetchDataPortalException(Server.DataPortalException ex, bool isSync, Csla.DataPortalClient.IDataPortalProxy proxy)
236 {
237 HandleDataPortalException("Fetch", ex, isSync, proxy);
238 }
239
247 public T Fetch(params object[] criteria)
248 {
249 return (T)Fetch(typeof(T), Server.DataPortal.GetCriteriaFromArray(criteria));
250 }
251
258 private object Fetch(Type objectType, object criteria)
259 {
260 try
261 {
262 return DoFetchAsync(objectType, criteria, true).Result;
263 }
264 catch (AggregateException ex)
265 {
266 if (ex.InnerExceptions.Count > 0)
267 throw ex.InnerExceptions[0];
268 else
269 throw;
270 }
271 }
272
279 public async Task<T> FetchAsync(params object[] criteria)
280 {
281 return (T)await DoFetchAsync(typeof(T), Server.DataPortal.GetCriteriaFromArray(criteria), false);
282 }
283
284 internal async Task<T> DoUpdateAsync(T obj, bool isSync)
285 {
286 Server.DataPortalResult result = null;
287 Server.DataPortalContext dpContext = null;
288 Type objectType = obj.GetType();
289 try
290 {
291 DataPortalClient.IDataPortalProxy proxy = null;
292 var factoryInfo = Csla.Server.ObjectFactoryAttribute.GetObjectFactoryAttribute(objectType);
293 if (factoryInfo != null)
294 {
295 Csla.Server.DataPortalMethodInfo method = null;
296 var factoryLoader = ApplicationContext.CurrentServiceProvider.GetService(typeof(Server.IObjectFactoryLoader)) as Server.IObjectFactoryLoader;
297 var factoryType = factoryLoader?.GetFactoryType(factoryInfo.FactoryTypeName);
298
299 if (obj is Core.ICommandObject)
300 {
301 if (!Csla.Rules.BusinessRules.HasPermission(ApplicationContext, Rules.AuthorizationActions.EditObject, obj))
303 "execute",
304 objectType.Name));
305 if (factoryType != null)
306 method = Server.DataPortalMethodCache.GetMethodInfo(factoryType, factoryInfo.ExecuteMethodName, new object[] { obj });
307 }
308 else
309 {
310 if (obj is Core.BusinessBase bbase)
311 {
312 if (bbase.IsDeleted)
313 {
314 if (!Csla.Rules.BusinessRules.HasPermission(ApplicationContext, Rules.AuthorizationActions.DeleteObject, obj))
316 "delete",
317 objectType.Name));
318 if (factoryType != null)
319 method = Server.DataPortalMethodCache.GetMethodInfo(factoryType, factoryInfo.DeleteMethodName,
320 new object[] { obj });
321 }
322 // must check the same authorization rules as for DataPortal_XYZ methods
323 else if (bbase.IsNew)
324 {
325 if (!Csla.Rules.BusinessRules.HasPermission(ApplicationContext, Rules.AuthorizationActions.CreateObject, obj))
327 "create",
328 objectType.Name));
329 if (factoryType != null)
330 method = Server.DataPortalMethodCache.GetMethodInfo(factoryType, factoryInfo.UpdateMethodName,
331 new object[] { obj });
332 }
333 else
334 {
335 if (!Csla.Rules.BusinessRules.HasPermission(ApplicationContext, Rules.AuthorizationActions.EditObject, obj))
337 "save",
338 objectType.Name));
339 if (factoryType != null)
340 method = Server.DataPortalMethodCache.GetMethodInfo(factoryType, factoryInfo.UpdateMethodName,
341 new object[] { obj });
342 }
343 }
344 else
345 {
346 if (!Csla.Rules.BusinessRules.HasPermission(ApplicationContext, Rules.AuthorizationActions.EditObject, obj))
348 "save",
349 objectType.Name));
350
351 if (factoryType != null)
352 method = Server.DataPortalMethodCache.GetMethodInfo(factoryType, factoryInfo.UpdateMethodName,
353 new object[] { obj });
354 }
355 }
356 if (method == null)
357 method = new Csla.Server.DataPortalMethodInfo();
358 proxy = GetDataPortalProxy(method.RunLocal);
359 }
360 else
361 {
362 Reflection.ServiceProviderMethodInfo method;
363 var criteria = Server.DataPortal.GetCriteriaArray(Server.EmptyCriteria.Instance);
364 if (obj is Core.ICommandObject)
365 {
366 if (!Csla.Rules.BusinessRules.HasPermission(ApplicationContext, Rules.AuthorizationActions.EditObject, obj))
368 "execute",
369 objectType.Name));
370 method = ServiceProviderMethodCaller.FindDataPortalMethod<ExecuteAttribute>(objectType, criteria, false);
371 }
372 else
373 {
374 if (obj is Core.BusinessBase bbase)
375 {
376 if (bbase.IsDeleted)
377 {
378 if (!Csla.Rules.BusinessRules.HasPermission(ApplicationContext, Rules.AuthorizationActions.DeleteObject, obj))
380 "delete",
381 objectType.Name));
382 method = ServiceProviderMethodCaller.FindDataPortalMethod<DeleteSelfAttribute>(objectType, criteria, false);
383 }
384 else if (bbase.IsNew)
385 {
386 if (!Csla.Rules.BusinessRules.HasPermission(ApplicationContext, Rules.AuthorizationActions.CreateObject, obj))
388 "create",
389 objectType.Name));
390 method = ServiceProviderMethodCaller.FindDataPortalMethod<InsertAttribute>(objectType, criteria, false);
391 }
392 else
393 {
394 if (!Csla.Rules.BusinessRules.HasPermission(ApplicationContext, Rules.AuthorizationActions.EditObject, obj))
396 "save",
397 objectType.Name));
398 method = ServiceProviderMethodCaller.FindDataPortalMethod<UpdateAttribute>(objectType, criteria, false);
399 }
400 }
401 else
402 {
403 method = ServiceProviderMethodCaller.FindDataPortalMethod<UpdateAttribute>(objectType, criteria, false);
404 }
405 }
406 proxy = GetDataPortalProxy(method);
407 }
408
409 dpContext =
410 new Server.DataPortalContext(ApplicationContext, GetPrincipal(), proxy.IsServerRemote);
411
412 try
413 {
414 if (!proxy.IsServerRemote && ApplicationContext.AutoCloneOnUpdate)
415 {
416 // when using local data portal, automatically
417 // clone original object before saving
418 if (obj is ICloneable cloneable)
419 obj = (T)cloneable.Clone();
420 }
421 result = await proxy.Update(obj, dpContext, isSync);
422 }
423 catch (AggregateException ex)
424 {
425 if (ex.InnerExceptions.Count > 0)
426 {
427 if (ex.InnerExceptions[0] is Server.DataPortalException dpe)
428 HandleUpdateDataPortalException(dpe, isSync, proxy);
429 }
430 throw new DataPortalException(
431 string.Format("DataPortal.Update {0}", Resources.Failed),
432 ex, null);
433 }
434 catch (Server.DataPortalException ex)
435 {
436 HandleUpdateDataPortalException(ex, isSync, proxy);
437 }
438 }
439 catch
440 {
441 throw;
442 }
443 return (T)result.ReturnObject;
444 }
445
446 private void HandleUpdateDataPortalException(Server.DataPortalException ex, bool isSync, Csla.DataPortalClient.IDataPortalProxy proxy)
447 {
448 HandleDataPortalException("Update", ex, isSync, proxy);
449 }
450
451 private void HandleDataPortalException(string operation, Server.DataPortalException ex, bool isSync, Csla.DataPortalClient.IDataPortalProxy proxy)
452 {
453 var result = ex.Result;
454 var original = ex.InnerException;
455 if (original.InnerException != null)
456 original = original.InnerException;
457 throw new DataPortalException(
458 String.Format("DataPortal.{2} {0} ({1})", Resources.Failed, original.Message, operation),
459 ex.InnerException, result.ReturnObject);
460 }
461
467 public T Update(T obj)
468 {
469 try
470 {
471 return DoUpdateAsync(obj, true).Result;
472 }
473 catch (AggregateException ex)
474 {
475 if (ex.InnerExceptions.Count > 0)
476 throw ex.InnerExceptions[0];
477 else
478 throw;
479 }
480 }
481
487 public async Task<T> UpdateAsync(T obj)
488 {
489 return await DoUpdateAsync(obj, false);
490 }
491
492 internal async Task DoDeleteAsync(Type objectType, object criteria, bool isSync)
493 {
494 Server.DataPortalResult result = null;
495 Server.DataPortalContext dpContext = null;
496 try
497 {
498 if (!Csla.Rules.BusinessRules.HasPermission(ApplicationContext, Rules.AuthorizationActions.DeleteObject, objectType, Server.DataPortal.GetCriteriaArray(criteria)))
500 "delete",
501 objectType.Name));
502
503 var method = ServiceProviderMethodCaller.FindDataPortalMethod<DeleteAttribute>(objectType, Server.DataPortal.GetCriteriaArray(criteria), false);
504 var proxy = GetDataPortalProxy(method);
505
506 dpContext = new Server.DataPortalContext(ApplicationContext, GetPrincipal(), proxy.IsServerRemote);
507
508 try
509 {
510 result = await proxy.Delete(objectType, criteria, dpContext, isSync);
511 }
512 catch (AggregateException ex)
513 {
514 if (ex.InnerExceptions.Count > 0)
515 {
516 var dpe = ex.InnerExceptions[0] as Server.DataPortalException;
517 if (dpe != null)
518 HandleDeleteDataPortalException(dpe, isSync, proxy);
519 }
520 throw new DataPortalException(
521 string.Format("DataPortal.Delete {0}", Resources.Failed),
522 ex, null);
523 }
524 catch (Server.DataPortalException ex)
525 {
526 HandleDeleteDataPortalException(ex, isSync, proxy);
527 }
528 }
529 catch
530 {
531 throw;
532 }
533 }
534
535 private void HandleDeleteDataPortalException(Server.DataPortalException ex, bool isSync, Csla.DataPortalClient.IDataPortalProxy proxy)
536 {
537 HandleDataPortalException("Delete", ex, isSync, proxy);
538 }
539
545 public void Delete(params object[] criteria)
546 {
547 Delete(typeof(T), Server.DataPortal.GetCriteriaFromArray(criteria));
548 }
549
556 private void Delete(Type objectType, object criteria)
557 {
558 try
559 {
560 var task = DoDeleteAsync(objectType, criteria, true);
561 if (!task.IsCompleted)
562 task.RunSynchronously();
563 if (task.Exception != null)
564 throw task.Exception;
565 }
566 catch (AggregateException ex)
567 {
568 if (ex.InnerExceptions.Count > 0)
569 throw ex.InnerExceptions[0];
570 else
571 throw;
572 }
573 }
574
580 public async Task DeleteAsync(params object[] criteria)
581 {
582 await DoDeleteAsync(typeof(T), Server.DataPortal.GetCriteriaFromArray(criteria), false);
583 }
584
590 public T Execute(T command)
591 {
592 return Update(command);
593 }
594
600 public async Task<T> ExecuteAsync(T command)
601 {
602 return await DoUpdateAsync(command, false);
603 }
604
605 private DataPortalClient.IDataPortalProxy GetDataPortalProxy(Reflection.ServiceProviderMethodInfo method)
606 {
607 if (method != null)
608 return GetDataPortalProxy(method.MethodInfo.RunLocal());
609 else
610 return GetDataPortalProxy(false);
611 }
612
613 private DataPortalClient.IDataPortalProxy GetDataPortalProxy(bool forceLocal)
614 {
615 if (forceLocal || ApplicationContext.IsOffline)
616 return ApplicationContext.CreateInstanceDI<Csla.Channels.Local.LocalProxy>();
617 else
618 return DataPortalProxy;
619 }
620
621 private System.Security.Principal.IPrincipal GetPrincipal()
622 {
623 if (ApplicationContext.AuthenticationType == "Windows")
624 {
625 // Windows integrated security
626 return null;
627 }
628 else
629 {
630 // we assume using the CSLA framework security
631 return ApplicationContext.User;
632 }
633 }
634
639 public T CreateChild()
640 {
641 var portal = new Server.ChildDataPortal(ApplicationContext);
642 return (T)(portal.Create(typeof(T)));
643 }
644
652 public T CreateChild(params object[] parameters)
653 {
654 var portal = new Server.ChildDataPortal(ApplicationContext);
655 return (T)(portal.Create(typeof(T), parameters));
656 }
657
662 public async Task<T> CreateChildAsync()
663 {
664 var portal = new Server.ChildDataPortal(ApplicationContext);
665 return await portal.CreateAsync<T>();
666 }
667
675 public async Task<T> CreateChildAsync(params object[] parameters)
676 {
677 var portal = new Server.ChildDataPortal(ApplicationContext);
678 return await portal.CreateAsync<T>(parameters);
679 }
680
685 public T FetchChild()
686 {
687 var portal = new Server.ChildDataPortal(ApplicationContext);
688 return (T)(portal.Fetch(typeof(T)));
689 }
690
698 public T FetchChild(params object[] parameters)
699 {
700 var portal = new Server.ChildDataPortal(ApplicationContext);
701 return (T)(portal.Fetch(typeof(T), parameters));
702 }
703
708 public async Task<T> FetchChildAsync()
709 {
710 var portal = new Server.ChildDataPortal(ApplicationContext);
711 return await portal.FetchAsync<T>();
712 }
713
721 public async Task<T> FetchChildAsync(params object[] parameters)
722 {
723 var portal = new Server.ChildDataPortal(ApplicationContext);
724 return await portal.FetchAsync<T>(parameters);
725 }
726
734 public void UpdateChild(T child)
735 {
736 var portal = new Server.ChildDataPortal(ApplicationContext);
737 portal.Update(child);
738 }
739
750 public void UpdateChild(object child, params object[] parameters)
751 {
752 var portal = new Server.ChildDataPortal(ApplicationContext);
753 portal.Update(child, parameters);
754 }
755
766 public void UpdateChild(T child, params object[] parameters)
767 {
768 var portal = new Server.ChildDataPortal(ApplicationContext);
769 portal.Update(child, parameters);
770 }
771
779 public async Task UpdateChildAsync(T child)
780 {
781 var portal = new Server.ChildDataPortal(ApplicationContext);
782 await portal.UpdateAsync(child).ConfigureAwait(false);
783 }
784
795 public async Task UpdateChildAsync(T child, params object[] parameters)
796 {
797 var portal = new Server.ChildDataPortal(ApplicationContext);
798 await portal.UpdateAsync(child, parameters).ConfigureAwait(false);
799 }
800
801 async Task<object> IDataPortal.CreateAsync(params object[] criteria) => Task.FromResult(await CreateAsync(criteria));
802 async Task<object> IDataPortal.FetchAsync(params object[] criteria) => Task.FromResult(await FetchAsync(criteria));
803 async Task<object> IDataPortal.UpdateAsync(object obj) => Task.FromResult(await UpdateAsync((T)obj));
804 async Task<object> IDataPortal.ExecuteAsync(object command) => Task.FromResult(await ExecuteAsync((T)command));
805 object IDataPortal.Create(params object[] criteria) => Create(criteria);
806 object IDataPortal.Fetch(params object[] criteria) => Fetch(criteria);
807 object IDataPortal.Execute(object obj) => Execute((T)obj);
808 object IDataPortal.Update(object obj) => Update((T)obj);
809
810 async Task<object> IChildDataPortal.CreateChildAsync(params object[] criteria) => Task.FromResult(await CreateChildAsync(criteria));
811 async Task<object> IChildDataPortal.FetchChildAsync(params object[] criteria) => Task.FromResult(await FetchChildAsync(criteria));
812 async Task IChildDataPortal.UpdateChildAsync(object obj, params object[] parameters) => await UpdateChildAsync((T)obj);
813 object IChildDataPortal.CreateChild(params object[] criteria) => CreateChild(criteria);
814 object IChildDataPortal.FetchChild(params object[] criteria) => FetchChild(criteria);
815 void IChildDataPortal.UpdateChild(object obj, params object[] parameters) => UpdateChild(obj, parameters);
816 }
817
818 internal static class Extensions
819 {
820 internal static bool RunLocal(this System.Reflection.MethodInfo t)
821 {
822 return t.CustomAttributes.Count(a => a.AttributeType.Equals(typeof(RunLocalAttribute))) > 0;
823 }
824 }
825}
Provides consistent context information between the client and server DataPortal objects.
static bool AutoCloneOnUpdate
Gets a value indicating whether objects should be automatically cloned by the data portal Update() me...
bool IsOffline
Gets or sets a value indicating whether the app should be considered "offline".
object CreateInstanceDI(Type objectType, params object[] parameters)
Creates an object using 'Activator.CreateInstance' using service provider (if one is available) to po...
static string AuthenticationType
Gets the authentication type being used by the CSLA .NET framework.
IPrincipal User
Get or set the current IPrincipal object representing the user's identity.
ClaimsPrincipal Principal
Get or set the current ClaimsPrincipal object representing the user's identity.
Implements a data portal proxy to relay data portal calls to an application server hosted locally in ...
Definition: LocalProxy.cs:25
Dictionary type that is serializable with the SerializationFormatterFactory.GetFormatter().
Client side data portal used for making asynchronous data portal calls in .NET.
Definition: DataPortalT.cs:24
T CreateChild()
Creates and initializes a new child business object.
Definition: DataPortalT.cs:639
async Task UpdateChildAsync(T child)
Inserts, updates or deletes an existing child business object.
Definition: DataPortalT.cs:779
void Delete(params object[] criteria)
Called by a factory method in a business class or by the UI to delete an object.
Definition: DataPortalT.cs:545
T Execute(T command)
Called by a factory method in a business class or by the UI to execute a command object.
Definition: DataPortalT.cs:590
async Task< T > CreateChildAsync()
Creates and initializes a new child business object.
Definition: DataPortalT.cs:662
async Task< T > CreateAsync(params object[] criteria)
Called by a factory method in a business class or by the UI to create a new object,...
Definition: DataPortalT.cs:184
T CreateChild(params object[] parameters)
Creates and initializes a new child business object.
Definition: DataPortalT.cs:652
void UpdateChild(T child)
Inserts, updates or deletes an existing child business object.
Definition: DataPortalT.cs:734
async Task< T > FetchChildAsync()
Fetches an existing child business object.
Definition: DataPortalT.cs:708
async Task DeleteAsync(params object[] criteria)
Called by a factory method in a business class or by the UI to delete an object.
Definition: DataPortalT.cs:580
T Update(T obj)
Called by a factory method in a business class or by the UI to update an object.
Definition: DataPortalT.cs:467
async Task UpdateChildAsync(T child, params object[] parameters)
Inserts, updates or deletes an existing child business object.
Definition: DataPortalT.cs:795
T Create(params object[] criteria)
Called by a factory method in a business class to create a new object, which is loaded with default v...
Definition: DataPortalT.cs:151
DataPortal(ApplicationContext applicationContext, DataPortalClient.IDataPortalProxy proxy)
Creates an instance of the type
Definition: DataPortalT.cs:30
async Task< T > ExecuteAsync(T command)
Called by a factory method in a business class or by the UI to execute a command object.
Definition: DataPortalT.cs:600
async Task< T > FetchChildAsync(params object[] parameters)
Fetches an existing child business object.
Definition: DataPortalT.cs:721
T Fetch(params object[] criteria)
Called by a factory method in a business class to Fetch a new object, which is loaded with default va...
Definition: DataPortalT.cs:247
async Task< T > UpdateAsync(T obj)
Called by a factory method in a business class or by the UI to update an object.
Definition: DataPortalT.cs:487
T FetchChild(params object[] parameters)
Fetches an existing child business object.
Definition: DataPortalT.cs:698
void UpdateChild(object child, params object[] parameters)
Inserts, updates or deletes an existing child business object.
Definition: DataPortalT.cs:750
async Task< T > FetchAsync(params object[] criteria)
Called by a factory method in a business class or by the UI to Fetch a new object,...
Definition: DataPortalT.cs:279
T FetchChild()
Fetches an existing child business object.
Definition: DataPortalT.cs:685
async Task< T > CreateChildAsync(params object[] parameters)
Creates and initializes a new child business object.
Definition: DataPortalT.cs:675
void UpdateChild(T child, params object[] parameters)
Inserts, updates or deletes an existing child business object.
Definition: DataPortalT.cs:766
Specifies a method used by the server-side data portal to delete domain object data during an update ...
Specifies a method used by the server-side data portal to load existing data into the domain object.
A strongly-typed resource class, for looking up localized strings, etc.
static string Failed
Looks up a localized string similar to failed.
static string UserNotAuthorizedException
Looks up a localized string similar to User not authorized to {0} object type {1}.
Tracks the business rules for a business object.
static bool HasPermission(ApplicationContext applicationContext, AuthorizationActions action, Type objectType)
Checks per-type authorization rules.
Provides consistent context information between the client and server DataPortal objects.
Specifies that the data portal should invoke a factory object rather than the business object.
Interface implemented by client-side data portal proxy objects.
Interface defining the members of the child data portal type.
Task UpdateChildAsync(object obj, params object[] parameters)
Called by a factory method in a business class or by the UI to update an object.
Task< object > FetchChildAsync(params object[] criteria)
Starts an asynchronous data portal operation to create a business object.
Task< object > CreateChildAsync(params object[] criteria)
Starts an asynchronous data portal operation to create a business object.
object CreateChild(params object[] criteria)
Called by a factory method in a business class to create a new object, which is loaded with default v...
void UpdateChild(object obj, params object[] parameters)
Called by the business object's Save() method to insert, update or delete an object in the database.
object FetchChild(params object[] criteria)
Called by a factory method in a business class to retrieve an object, which is loaded with values fro...
Interface defining the members of the data portal type.
Definition: IDataPortalT.cs:17
object Update(object obj)
Insert, update or delete an object in the database.
Task< object > CreateAsync(params object[] criteria)
Starts an asynchronous data portal operation to create a business object.
object Fetch(params object[] criteria)
Called by a factory method in a business class to retrieve an object, which is loaded with values fro...
Task< object > UpdateAsync(object obj)
Called by a factory method in a business class or by the UI to update an object.
object Execute(object obj)
Called to execute a Command object on the server.
Task< object > ExecuteAsync(object command)
Called by a factory method in a business class or by the UI to execute a command object.
object Create(params object[] criteria)
Called by a factory method in a business class to create a new object, which is loaded with default v...
Task< object > FetchAsync(params object[] criteria)
Starts an asynchronous data portal operation to create a business object.
@ Error
Represents a serious business rule violation that should cause an object to be considered invalid.