The requested page is not available for the requested platform. You are viewing the content for .NET Framework 4.5.2+ platform.
.NET Framework 4.5.2+
.NET Framework 4.5.2+
.NET Standard 2.0+
.NET Core 3.0+

IObjectSpace.GetObjects(Type, CriteriaOperator, IList<SortProperty>, Boolean) Method

Returns a sorted IList collection of objects of the specified type, retrieved to the current Object Space and filtered according to the specified criteria.

Namespace: DevExpress.ExpressApp

Assembly: DevExpress.ExpressApp.v19.2.dll

Declaration

IList GetObjects(
    Type type,
    CriteriaOperator criteria,
    IList<SortProperty> sorting,
    bool inTransaction
)
Function GetObjects(
    type As Type,
    criteria As CriteriaOperator,
    sorting As IList(Of SortProperty),
    inTransaction As Boolean
) As IList
IList GetObjects(
    Type type,
    CriteriaOperator criteria,
    IList<SortProperty> sorting,
    bool inTransaction
)
Function GetObjects(
    type As Type,
    criteria As CriteriaOperator,
    sorting As IList(Of SortProperty),
    inTransaction As Boolean
) As IList
IList GetObjects(
    Type type,
    CriteriaOperator criteria,
    IList<SortProperty> sorting,
    bool inTransaction
)
Function GetObjects(
    type As Type,
    criteria As CriteriaOperator,
    sorting As IList(Of SortProperty),
    inTransaction As Boolean
) As IList

Parameters

Name Type Description
type Type

The type of objects that are retrieved.

criteria CriteriaOperator

A CriteriaOperator which specifies the criteria for object selection.

sorting IList<SortProperty>

An IList<SortProperty> object that specifies sorting.

inTransaction Boolean

true, if the filter takes unsaved changes into account; otherwise, false. Has effect in XPO only.

Parameters

Name Type Description
type Type

The type of objects that are retrieved.

criteria CriteriaOperator

A CriteriaOperator which specifies the criteria for object selection.

sorting IList<SortProperty>

An IList<SortProperty> object that specifies sorting.

inTransaction Boolean

true, if the filter takes unsaved changes into account; otherwise, false. Has effect in XPO only.

Parameters

Name Type Description
type Type

The type of objects that are retrieved.

criteria CriteriaOperator

A CriteriaOperator which specifies the criteria for object selection.

sorting IList<SortProperty>

An IList<SortProperty> object that specifies sorting.

inTransaction Boolean

true, if the filter takes unsaved changes into account; otherwise, false. Has effect in XPO only.

Returns

Type Description
IList

A IList collection that contains the persistent objects of the specified type. Only objects that satisfy the specified criteria will be retrieved to this collection.

Returns

Type Description
IList

A IList collection that contains the persistent objects of the specified type. Only objects that satisfy the specified criteria will be retrieved to this collection.

Returns

Type Description
IList

A IList collection that contains the persistent objects of the specified type. Only objects that satisfy the specified criteria will be retrieved to this collection.

Remarks

The following example uses a Parametrized Action to search for a Person by LastName, and then assigns the deferred task with the nearest due date to that person.

using System.Collections;
using System.Collections.Generic;
using DevExpress.Data.Filtering;
using DevExpress.ExpressApp;
using DevExpress.ExpressApp.Actions;
using DevExpress.Persistent.Base;
using DevExpress.Persistent.Base.General;
using DevExpress.Persistent.BaseImpl;
using DevExpress.Xpo;
using DevExpress.Xpo.DB;
// ...
public class AssignTasksController : ObjectViewController<ListView, MainDemo.Module.BusinessObjects.DemoTask> {
    public AssignTasksController() {
        ParametrizedAction assignTasksAction = new ParametrizedAction(
            this, "AssignTasks", PredefinedCategory.Edit, typeof(string));
        assignTasksAction.Execute += AssignTasksAction_Execute;
    }
    private void AssignTasksAction_Execute(object sender, ParametrizedActionExecuteEventArgs e) {
        IObjectSpace objectSpace = View.ObjectSpace;
        string personParamValue = e.ParameterCurrentValue as string;
        CriteriaOperator personCriteria = CriteriaOperator.Parse("Contains([LastName], ?)", personParamValue);
        Person person = (Person)objectSpace.FindObject(typeof(Person), personCriteria);
        if(person != null) {
            List<SortProperty> sorting = new List<SortProperty>();
            sorting.Add(new SortProperty("DueDate", SortingDirection.Descending));
            CriteriaOperator taskCriteria = CriteriaOperator.Parse("[Status] = ?", TaskStatus.Deferred);
            IList tasks = objectSpace.GetObjects(
                typeof(MainDemo.Module.BusinessObjects.DemoTask), taskCriteria, sorting, false);
            if(tasks.Count > 0) {
                MainDemo.Module.BusinessObjects.DemoTask task = (MainDemo.Module.BusinessObjects.DemoTask)tasks[0];
                task.AssignedTo = person;
            }
        }
    }
}

When implementing the IObjectSpace interface in the BaseObjectSpace class's descendant, don't implement the GetObjects method. It's implemented in the BaseObjectSpace class. To get the specified objects, the BaseObjectSpace.GetObjects(Type type, CriteriaOperator criteria, bool inTransaction) method invokes a protected virtual CreateCollection method that does nothing and returns null. So, you should override the CreateCollection method in your descendant.

See Also