Saturday, March 17, 2018

ObjectSpace

BaseObjectSpace Members

A base class for the classes that implement the IObjectSpace interface.

Expanded Public Constructors

Show: Inherited
 NameDescription
Public methodBaseObjectSpaceCreates a new instance of the BaseObjectSpace class.
Top

Expanded Public Properties

Show: Inherited
 NameDescription
Public propertyCanFilterByNonPersistentMembersFor internal use.
Public propertyConnectionGets the connection to the underlying data source.
Public propertyDatabaseGets the name of the database.
Public propertyIsCommittingIndicates whether the Object Space is currently committing the changes made to its object(s).
Public propertyIsConnectedIndicates whether the BaseObjectSpace is connected to the database.
Public propertyIsDeletingIndicates whether the current Object Space is about to delete an object(s).
Public propertyIsDisposedGets a value indicating whether an Object Space has been disposed of.
Public propertyIsModifiedSpecifies whether objects belonging to the current Object Space are modified.
Public propertyIsReloadingGets a boolean value indicating whether or not the Object Space is reloading.
Public propertyLockingCheckEnabledSpecifies whether or not the additional locking check is performed.
Public propertyModifiedObjectsReturns a collection of objects that have been created, modified or deleted in the current object context.
Public propertyNonPersistentChangesEnabledSpecifies whether the BaseObjectSpace is marked as modified (see IsModified) when a non-persistent property is changed.
Public propertyOwnerSpecifies the View owning the current Object Space.
Public propertyTypesInfoGets information on the business classes added to the Application Model (see IModelBOModel).
Top

Expanded Public Methods

Show: Inherited
 NameDescription
Public methodApplyCriteriaFilters a particular collection on the server side.
Public methodApplyFilterFilters a particular collection on the client side.
Public methodCanApplyCriteriaIndicates whether collections of a particular type can be filtered on the server side.
Public methodCanApplyFilterIndicates whether a particular collection can be filtered on the client side.
Public methodCanInstantiateIndicates whether instances of a particular type can be created.
Public methodCommitChangesSaves all the changes made to the persistent objects belonging to the current Object Space to the database.
Public methodContainsIndicates whether a specified object belongs to the current Object Space.
Public methodStatic memberConvertExpressionsStringToExpressionsListReturns the list of DataViewExpression objects converted from the passed semicolon-separated expressions list.
Public methodStatic memberConvertSortingToStringReturns the string representation of a given sort list.
Public methodStatic memberConvertStringToSortingConverts the sorting string into the sorting list.
Public methodCreateCollectionOverloaded. Creates and initializes a collection of objects of the specified type.
Public methodCreateDataViewOverloaded. Returns a list of data records retrieved from a database without loading complete business classes (a data view). Values in each data record can be obtained from specific business class properties directly, or be evaluated by the database server using complex expressions.
Public methodCreateInstantFeedbackCollection
Public methodCreateNestedObjectSpaceCreates a nested Object Space.
Public methodCreateObjectCreates an object of the specified type.
Public methodCreateObjectCreates an object of the type designated by the specified generic type parameter.
Public methodCreateParseCriteriaScopeUsed when parsing a CriteriaOperator represented by a string and containing persistent objects.
Public methodCreateServerCollectionCreates and initializes a new instance of the EFServerCollection or DevExpress.Xpo.XPServerCollectionSource class with criteria-specific options.
Public methodDeleteOverloaded. Marks the specified persistent object and its aggregated objects as deleted from persistent storage.
Public methodDisposeReleases all resources used by an BaseObjectSpace object.
Public methodEnableObjectDeletionOnRemoveEnables/disables the deletion of persistent objects from the data source when they are removed from the specified collection.
Public methodStatic memberEqualsDetermines whether the specified System.Object instances are considered equal. (Inherited from System.Object)
Public methodEqualsDetermines whether the specified System.Object is equal to the current System.Object. (Inherited from System.Object)
Public methodEvaluateEvaluates the specified criteria for business objects of the given type.
Public methodFindObjectOverloaded. Searches for the first object of the specified type, matching the specified criteria.
Public methodFindObjectOverloaded. Searches for the first object of the type designated by the specified generic type parameter, matching the specified criteria.
Public methodGetAssociatedCollectionCriteriaReturns the criteria applied to a specific object's associated collection property.
Public methodGetCollectionObjectType
Public methodGetCollectionSortingReturns the sort settings for a particular collection.
Public methodGetCriteriaReturns the criteria used to filter a particular collection on the server side.
Public methodGetDisplayablePropertiesGets the properties considered visible by the specified collection.
Public methodGetEvaluatorContextDescriptorCreates an instance of the EvaluatorContextDescriptor that is used to supply metadata on the specified type to the ExpressionEvaluator objects.
Public methodGetExpressionEvaluatorOverloaded. Creates an ExpressionEvaluator object that is used to evaluate whether objects of the specified type satisfy a particular criteria.
Public methodGetFilterReturns the criteria used to filter a particular collection on the client side.
Public methodGetHashCodeServes as a hash function for a particular type. System.Object.GetHashCode is suitable for use in hashing algorithms and data structures like a hash table. (Inherited from System.Object)
Public methodGetIntermediateObjectReferencesFor internal use.
Public methodGetKeyPropertyNameGets the name of the specified type's key property.
Public methodGetKeyPropertyTypeGets the key property type of the specified business type.
Public methodGetKeyValueOverloaded. Returns the key property's value of the specified object.
Public methodStatic memberGetKeyValueOverloaded. Returns the key property's value of the specified persistent object.
Public methodGetKeyValueAsStringOverloaded. Returns the key property's value of the specified object, converted to a string representation.
Public methodStatic memberGetKeyValueAsStringOverloaded.
Public methodGetObjectRetrieves an object that corresponds to a specific object from another Object Space or to a specific record from a data view created by the IObjectSpace.CreateDataView method.
Public methodGetObjectRetrieves an object from another Object Space to the current Object Space. The returned object is cast by the type designated by the specified generic type parameter.
Public methodGetObjectByHandleReturns the object with the specified handle.
Public methodGetObjectByKeyReturns the persistent object that has the specified value for its key property.
Public methodGetObjectByKeyReturns a persistent object of the type designated by the specified generic type parameter, with the specified value for its key property.
Public methodGetObjectHandleReturns an object's handle.
Public methodGetObjectKeyConverts the key property value string representation into its actual type.
Public methodGetObjectsOverloaded. Returns an IList collection of objects of the specified type, retrieved to the current Object Space and filtered according to the specified criteria.
Public methodGetObjectsOverloaded. Returns an IList collection of objects of the specified type, retrieved to the current Object Space and filtered according to the specified criteria.
Public methodGetObjectsCountReturns the number of objects specified.
Public methodGetObjectsCriteriaConstructs a criteria that can be used to select the specified list of business objects.
Public methodGetObjectsQueryGets a queryable data structure that provides functionality to evaluate queries against a specific business object type.
Public methodGetObjectsToDeleteReturns a collection of persistent objects that will be deleted when the current transaction is committed, including objects that will be deleted in the parent transaction(s), optionally.
Public methodGetObjectsToSaveReturns a collection of persistent objects that will be saved when the current transaction is committed, including objects that will be saved in the parent transaction(s), optionally.
Public methodGetObjectTypeReturns the type of the specified business object.
Public methodGetTopReturnedObjectsCountReturns the maximum number of objects to be retrieved by the specified collection from a data store.
Public methodGetTypeGets the System.Type of the current instance. (Inherited from System.Object)
Public methodIsCollectionLoadedIndicates whether a particular collection is loaded with objects from the database.
Public methodIsDeletedObjectIndicates whether the specified persistent object is deleted from the database.
Public methodIsDeletionDeferredTypeReturns a value that indicates if the deferred deletion is enabled for persistent objects of a given type.
Public methodIsDisposedObjectDetermines whether an object has been disposed of.
Public methodIsIntermediateObjectFor internal use.
Public methodIsKnownTypeReturns the boolean value indicating whether or not the specified type is known by the BaseObjectSpace.
Public methodIsNewObjectIndicates whether a specified object has been created but has not been saved to the database.
Public methodIsObjectDeletionOnRemoveEnabledIndicates whether the deletion of persistent objects from the data source when they are removed from the specified collection is enabled.
Public methodIsObjectFitForCriteriaOverloaded. Specifies whether a particular object satisfies the specified criteria.
Public methodIsObjectToDeleteIndicates whether the specified object has been deleted but not committed in the current object context or the transaction currently in progress.
Public methodIsObjectToSaveIndicates whether the specified object has been added, deleted or modified, but not committed in the current object context or the transaction currently in progress.
Public methodStatic memberObjectKeyValuesEqual
Public methodParseCriteriaTries to convert the specified string representation of an expression to its DevExpress.Data.Filtering.CriteriaOperator equivalent.
Public methodStatic memberReferenceEqualsDetermines whether the specified System.Object instances are the same instance. (Inherited from System.Object)
Public methodRefreshUpdates the persistent objects belonging to the current Object Space.
Public methodReloadCollectionClears the specified collection.
Public methodReloadObjectUpdates the specified object in the current Object Space with data from the data source.
Public methodRemoveFromModifiedObjectsRemoves the specified object from the object context or the list of objects to be committed.
Public methodRollbackCancels the changes made to the persistent objects belonging to the current Object Space.
Public methodSetCollectionSortingApplies the specified sorting to a given collection.
Public methodSetDisplayablePropertiesChanges the properties considered visible by a particular collection.
Public methodSetModifiedOverloaded. Sets the state of the specified object to be Modified.
Public methodSetPrefetchPropertyNames
Public methodSetTopReturnedObjectsCountSets the maximum number of objects that can be retrieved from the specified collection in a data store.
Public methodToStringReturns a System.String that represents the current System.Object. (Inherited from System.Object)
Top

Expanded Public Fields

Show: Inherited
 NameDescription
Public fieldStatic memberCompositeKeyPropertyType
Top

Expanded Public Events

Show: Inherited
 NameDescription
Public eventCommittedRaised after saving changes made to persistent objects belonging to the current Object Space to the database.
Public eventCommittingOccurs before saving the persistent objects belonging to the current Object Space to the database.
Public eventConfirmationRequiredOccurs when performing refresh or rollback operations with the current Object Space's persistent objects.
Public eventConnectedOccurs after a connection to a database has been established.
Public eventCustomCommitChangesReplaces the default process for committing changes made to persistent objects with a custom one.
Public eventCustomDeleteObjectsOccurs to replace the default process of deleting persistent objects with a custom one.
Public eventCustomRefreshOccurs to replace the default process of refreshing persistent objects with a custom one.
Public eventCustomRollBackOccurs to replace the default process of persistent objects rollback with a custom one.
Public eventDisposedOccurs before an Object Space is disposed of.
Public eventModifiedChangedOccurs when the current Object Space's IsModified state is changed.
Public eventObjectChangedRaised when a persistent object is created, changed or deleted.
Public eventObjectDeletedOccurs after the specified objects have been deleted.
Public eventObjectDeletingOccurs when the specified objects are about to be deleted.
Public eventObjectEndEditOccurs after ending an edit operation taking place on the specified object.
Public eventObjectReloadedOccurs after an object has been reloaded from the database.
Public eventObjectSavedOccurs after saving changes made to a specified persistent object to the database.
Public eventObjectSavingRaised before saving changes made to a specified persistent object to the database.
Public eventRefreshingOccurs before refreshing the current Object Space's persistent objects.
Public eventReloadedOccurs when the Rollback or Refresh method is called.
Public eventRollingBackOccurs before rolling back the changes made to the current Object Space's persistent objects.
Top

Expanded See Also

Pop-up Window

Add an Action that Displays a Pop-up Window

In this lesson, you will learn how to create an Action that shows a pop-up window. This type of Action is useful when you want a user to input several parameters in a pop-up dialog before an Action is executed.
Note
Before proceeding, take a moment to review the following lessons.

Expanded Create a Controller and a PopupWindowShowAction

  • Add a new View Controller to the MySolution.Module project, as described in the Add a Simple Action lesson. Name it PopupNotesController.
  • Right-click the MySolution.Module | Controllers | PopupNotesController.cs (PopupNotesController.vb) file, and choose View Designer to invoke the Designer.
  • Drag the PopupWindowShowAction component from the DX.17.2: XAF Actions tab to the Designer. In the popupWindowShowAction1 "Properties" window, set the Name and Id properties to "ShowNotesAction", and set the Caption property to "Show Notes". Set the Category property to "Edit". This property specifies the Action group to which the current Action belongs. All Actions within a single group are displayed together sequentially in a UI.
  • To activate the PopupNotesController for DemoTask Detail Views only, set the Controller's ViewController.TargetObjectType property to MySolution.Module.DemoTask, and set the ViewController.TargetViewType to DetailView.

Expanded Specify the Popup List View

Focus the ShowNotesAction component. In the Properties window, switch to the Events view. Double-click the CustomizePopupWindowParams event, add the "using" ("Imports" in VB) directive according to your ORM, and replace the auto-generated event handler code with the following code.
C#
VB
using DevExpress.Persistent.BaseImpl; //For XPO 
using DevExpress.Persistent.BaseImpl.EF; //For EF 
// ... 
private void ShowNotesAction_CustomizePopupWindowParams(object sender, CustomizePopupWindowParamsEventArgs args) {
    IObjectSpace objectSpace = Application.CreateObjectSpace(typeof(Note));
    string noteListViewId = Application.FindLookupListViewId(typeof(Note));
    CollectionSourceBase collectionSource = Application.CreateCollectionSource(objectSpace, typeof(Note), noteListViewId);
    args.View = Application.CreateListView(noteListViewId, collectionSource, true);
    //Optionally customize the window display settings. 
    //args.Size = new System.Drawing.Size(600, 400); 
    //args.Maximized = true; 
    //args.IsSizeable = false; 
}
For details on this event, refer to the PopupWindowShowAction.CustomizePopupWindowParams topic. The code above will create the Notes List View when generating the pop-up window.
To create a List View, use the XafApplication object again (as you did in the previous lesson). In the code above, the XafApplication helps you find the ID of the required List View in the Application Model. Note that a collection source for the List View is created in a separate Object Space. To create the Object Space, use XafApplication again.

Expanded Handle the Execute Event

In the Controller's Designer, switch to the Events view in the Properties window with the Action's properties. Double-click the Execute event, add the "using" ("Imports" in VB) directive and replace the auto-generated event handler code with the following code.
C#
VB
using MySolution.Module.BusinessObjects;
// ... 
private void ShowNotesAction_Execute(object sender, PopupWindowShowActionExecuteEventArgs args) {
    DemoTask task = (DemoTask)View.CurrentObject;
    foreach(Note note in args.PopupWindowViewSelectedObjects) {
        if(!string.IsNullOrEmpty(task.Description)) {
            task.Description += Environment.NewLine;
        }
        task.Description += note.Text;
    }
    if(((DetailView)View).ViewEditMode == ViewEditMode.View) {
        View.ObjectSpace.CommitChanges();
    }
}
The Execute event is raised when clicking the OK button in the pop-up window. When the handler above is executed, the Text property value of the selected Note object will be appended to the Task.Description property value.
In this code, access the object selected in the pop-up window by using the event handler's PopupWindowShowActionExecuteEventArgs.PopupWindowViewSelectedObjects parameter.
To refresh the editor representing the modified Description property, first find its PropertyEditor in the current View's CompositeView.Items collection using the CompositeView.FindItem method. To update the value displayed by the Property Editor's editor, call the PropertyEditor.ReadValue method.
In ASP.NET Web applications, Detail Views are displayed in View and Edit modes. When the ShowNotes Action is activated for a DemoTask Detail View that is in View mode, the changes made to the DemoTask.Description property should be saved to the database. For this purpose, the CommitChanges method of the current View's ObjectSpace is called. When you use the ShowNotes Action in a DemoTask Detail View that is in Edit mode, the changes can be saved or rolled back via the corresponding built-in Actions.

Expanded Add Notes to the UI

  • To add the Note business class to the UI construction process, add it to the Application Model.
  • If your ORM is Entity Framework, you should register the Note type in DbContext before proceeding to the next step. Edit the BusinessObjects\MySolutionDbContext.cs file as shown below.
    C#
    VB
    public class MySolutionDbContext : DbContext {
        //... 
        public DbSet Notes { get; set; } 
    }
    
  • To add the Note business class from the Business Class Library use the Module Designer. Double-click the Module.cs (Module.vb) file within the MySolution.Module project. The Exported Types section of the designer lists the business classes that can be added.
    • If you are using XPO:
      Locate the Referenced Assemblies | DevExpress.Persistent.BaseImpl.v17.2 | Note node.
    • If you are using Entity Framework:
      Locate the Referenced Assemblies | DevExpress.Persistent.BaseImpl.EF.v17.2 | Note node.
    Select this node and press the SPACEBAR, or right-click it and choose Use Type in Application in the invoked context menu.
  • Build the project.
  • Note
    To create Note objects, you should add the Note item to the New Action's items. To do this, perform the steps demonstrated in the Add an Item to the New Action lesson.
    To access the existing Note objects, add the Note item to the ShowNavigationItem Action's items (displayed by the navigation control). To do this, perform the steps demonstrated in the Add an Item to the Navigation Controllesson.

Expanded Result

Run the WinForms or ASP.NET application. Create several Note objects via the New Action. Select the Task item in the navigation control. Double-click one of the listed Task objects. In the invoked detail form, find the Show Notes toolbar button that represents the implemented Action. Click this button, which will invoke a pop-up window. Select a Note object in the list and click OK. Check to see that the Task.Description property value has been changed.
Tip
For an example of how to create and show a Detail View, refer to the How to: Create and Show a Detail View of the Selected Object in a Popup Window topic.
You can view the code demonstrated in this tutorial in the MySolution.Module | Controllers | PopupNotesController.cs (PopupNotesController.vb) file of the Main Demo installed with XAF. The MainDemo application is installed in %PUBLIC%\Documents\DevExpress Demos 17.2\Components\eXpressApp Framework\MainDemo by default. The ASP.NET version of this demo is available online at http://demos.devexpress.com/XAF/MainDemo/.

Next Lesson: Add an Action with Option Selection

Expanded See Also