9using System.ComponentModel;
14using System.Threading.Tasks;
42 internal static void OnDataPortalInitInvoke(
object e)
52 internal static void OnDataPortalInvokeComplete(DataPortalEventArgs e)
68 return dp.Create(criteria);
91 public static object Create(Type objectType,
object criteria)
221 return dp.Fetch(criteria);
235 internal static object Fetch(Type objectType,
object criteria)
322 dp.FetchCompleted += callback;
323 dp.BeginFetch(criteria, userState);
337 return await dp.FetchAsync();
354 return await dp.FetchAsync(criteria);
373 return dp.Update(obj);
451 internal static void Delete(Type objectType,
object criteria)
499 dp.DeleteCompleted += callback;
500 dp.BeginDelete(criteria, userState);
517 await dp.DeleteAsync(criteria);
589 dp.ExecuteCompleted += callback;
590 dp.BeginExecute(obj, userState);
607 return await dp.ExecuteAsync(command);
619 Server.ChildDataPortal portal =
new Server.ChildDataPortal();
620 return (T)(portal.Create(typeof(T)));
635 Server.ChildDataPortal portal =
new Server.ChildDataPortal();
636 return (T)(portal.Create(typeof(T), parameters));
648 Server.ChildDataPortal portal =
new Server.ChildDataPortal();
649 return await portal.CreateAsync<T>();
664 Server.ChildDataPortal portal =
new Server.ChildDataPortal();
665 return await portal.CreateAsync<T>(parameters);
677 Server.ChildDataPortal portal =
new Server.ChildDataPortal();
678 return (T)(portal.Fetch(typeof(T)));
693 Server.ChildDataPortal portal =
new Server.ChildDataPortal();
694 return (T)(portal.Fetch(typeof(T), parameters));
706 Server.ChildDataPortal portal =
new Server.ChildDataPortal();
707 return await portal.FetchAsync<T>();
722 Server.ChildDataPortal portal =
new Server.ChildDataPortal();
723 return await portal.FetchAsync<T>(parameters);
735 Server.ChildDataPortal portal =
new Server.ChildDataPortal();
736 portal.Update(child);
749 public static void UpdateChild(
object child, params
object[] parameters)
751 Server.ChildDataPortal portal =
new Server.ChildDataPortal();
752 portal.Update(child, parameters);
764 Server.ChildDataPortal portal =
new Server.ChildDataPortal();
765 await portal.UpdateAsync(child).ConfigureAwait(
false);
780 Server.ChildDataPortal portal =
new Server.ChildDataPortal();
781 await portal.UpdateAsync(child, parameters).ConfigureAwait(
false);
784 private static DataPortalClient.IDataPortalProxyFactory _dataProxyFactory;
789 internal static void LoadDataPortalProxyFactory()
791 if (_dataProxyFactory ==
null)
793 if (
String.IsNullOrEmpty(ApplicationContext.DataPortalProxyFactory) || ApplicationContext.DataPortalProxyFactory ==
"Default")
795 _dataProxyFactory =
new DataPortalClient.DataPortalProxyFactory();
799 var proxyFactoryType =
800 Type.GetType(ApplicationContext.DataPortalProxyFactory) ??
801 throw new InvalidOperationException(
804 _dataProxyFactory = (DataPortalClient.IDataPortalProxyFactory)MethodCaller.CreateInstance(proxyFactoryType);
818 if (_dataProxyFactory ==
null)
819 LoadDataPortalProxyFactory();
820 return _dataProxyFactory;
824 _dataProxyFactory = value;
840 get {
return ApplicationContext.DataPortalProxy; }
841 set { ApplicationContext.DataPortalProxy = value; }
851 _dataProxyFactory =
null;
861 if (_dataProxyFactory !=
null)
863 _dataProxyFactory.ResetProxyType();
872 [EditorBrowsable(EditorBrowsableState.Never)]
873 [Obsolete(
"Proxies no longer cached")]
Provides information about the DataPortal call.
This is the client-side DataPortal.
static T Update< T >(T obj)
Called by the business object's Save() method to insert, update or delete an object in the database.
static T Create< T >()
Called by a factory method in a business class to create a new object, which is loaded with default v...
static async Task< T > FetchChildAsync< T >()
Fetchs and initializes a new child business object.
static void BeginExecute< T >(T obj, EventHandler< DataPortalResult< T > > callback)
Starts an asynchronous data portal operation to execute a command object.
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,...
static void ResetProxyFactory()
Resets the data portal proxy type, so the next data portal call will reload the proxy type based on c...
static async Task< T > CreateAsync< T >()
Starts an asynchronous data portal operation to create a business object.
static void ResetProxyType()
Resets the data portal proxy type, so the next data portal call will reload the proxy type based on c...
static string ProxyTypeName
Gets or sets the assembly qualified type name of the proxy object to be loaded by the data portal.
T Update(T obj)
Called by a factory method in a business class or by the UI to update an object.
static T CreateChild< T >()
Creates and initializes a new child business object.
static void UpdateChild(object child)
Inserts, updates or deletes an existing child business object.
static void BeginFetch< T >(EventHandler< DataPortalResult< T > > callback)
Starts an asynchronous data portal operation to fetch a business object.
void BeginUpdate(T obj)
Called by a factory method in a business class or by the UI to update an object.
static async Task UpdateChildAsync(object child, params object[] parameters)
Inserts, updates or deletes an existing child business object.
static void BeginDelete< T >(object criteria, EventHandler< DataPortalResult< T > > callback)
Starts an asynchronous data portal operation to delete a business object.
static void BeginCreate< T >(EventHandler< DataPortalResult< T > > callback)
Starts an asynchronous data portal operation to create a business object.
static Action< DataPortalEventArgs > DataPortalInvoke
Raised by DataPortal prior to calling the requested server-side DataPortal method.
static async Task< T > CreateChildAsync< T >()
Creates and initializes a new child business object.
EventHandler< DataPortalResult< T > > UpdateCompleted
Event raised when the operation has completed.
static async Task< T > ExecuteAsync< T >(T command)
Starts an asynchronous data portal operation to execute a command object.
static void BeginUpdate< T >(T obj, EventHandler< DataPortalResult< T > > callback)
Starts an asynchronous data portal operation to update a business object.
static async Task UpdateChildAsync(object child)
Inserts, updates or deletes an existing child business object.
static void ReleaseProxy()
Releases any remote data portal proxy object, so the next data portal call will create a new proxy in...
static async Task< T > UpdateAsync< T >(T obj)
Starts an asynchronous data portal operation to update a business object.
async Task< T > UpdateAsync(T obj)
Called by a factory method in a business class or by the UI to update an object.
static T Execute< T >(T obj)
Called to execute a Command object on the server.
void BeginCreate()
Called by a factory method in a business class or by the UI to create a new object,...
EventHandler< DataPortalResult< T > > CreateCompleted
Event raised when the operation has completed.
static object Create(Type objectType, object criteria)
Called by a factory method in a business class to create a new object, which is loaded with default v...
static async Task< T > FetchAsync< T >()
Starts an asynchronous data portal operation to fetch a business object.
static async Task DeleteAsync< T >(params object[] criteria)
Starts an asynchronous data portal operation to delete a business object.
static void UpdateChild(object child, params object[] parameters)
Inserts, updates or deletes an existing child business object.
static Action< System.Object > DataPortalInitInvoke
Raised by DataPortal before it starts setting up to call a server-side DataPortal method.
static Action< DataPortalEventArgs > DataPortalInvokeComplete
Raised by DataPortal after the requested server-side DataPortal method call is complete.
static DataPortalClient.IDataPortalProxyFactory ProxyFactory
Gets or sets a reference to a ProxyFactory object that is used to create an instance of the data port...
static T FetchChild< T >()
Creates and loads an existing child business object.
static T Fetch< T >()
Called by a factory method in a business class to retrieve an object, which is loaded with values fro...
static void Delete< T >(params object[] criteria)
Called by a Shared (static in C#) method in the business class to cause immediate deletion of a speci...
DataPortalResult defines the results of DataPortal operation.
A strongly-typed resource class, for looking up localized strings, etc.
static string UnableToLoadDataPortalProxyFactory
Looks up a localized string similar to Unable to load DataPortalProxyFactory {0}.
Implements the server-side DataPortal message router as discussed in Chapter 4.
Empty criteria used by the data portal as a placeholder for a create/fetch request that has no criter...
static EmptyCriteria Instance
Gets an instance of EmptyCriteria
Interface to be implemented by any object that supports serialization by the SerializationFormatterFa...