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.FindObject(Type, CriteriaOperator, Boolean) Method

Searches for the first object that matches the specified criteria and is of the specified type.

Namespace: DevExpress.ExpressApp

Assembly: DevExpress.ExpressApp.v19.2.dll

Declaration

object FindObject(
    Type objectType,
    CriteriaOperator criteria,
    bool inTransaction
)
Function FindObject(
    objectType As Type,
    criteria As CriteriaOperator,
    inTransaction As Boolean
) As Object
object FindObject(
    Type objectType,
    CriteriaOperator criteria,
    bool inTransaction
)
Function FindObject(
    objectType As Type,
    criteria As CriteriaOperator,
    inTransaction As Boolean
) As Object
object FindObject(
    Type objectType,
    CriteriaOperator criteria,
    bool inTransaction
)
Function FindObject(
    objectType As Type,
    criteria As CriteriaOperator,
    inTransaction As Boolean
) As Object

Parameters

Name Type Description
objectType Type

A Type object which represents the type of objects to search for.

criteria CriteriaOperator

A CriteriaOperator descendant which represents the criteria for matching persistent objects.

inTransaction Boolean

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

Parameters

Name Type Description
objectType Type

A Type object which represents the type of objects to search for.

criteria CriteriaOperator

A CriteriaOperator descendant which represents the criteria for matching persistent objects.

inTransaction Boolean

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

Parameters

Name Type Description
objectType Type

A Type object which represents the type of objects to search for.

criteria CriteriaOperator

A CriteriaOperator descendant which represents the criteria for matching persistent objects.

inTransaction Boolean

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

Returns

Type Description
Object

An object which represents the first persistent object which matches the specified criteria. null (Nothing in Visual Basic) if there is no persistent object which matches the criteria.

Returns

Type Description
Object

An object which represents the first persistent object which matches the specified criteria. null (Nothing in Visual Basic) if there is no persistent object which matches the criteria.

Returns

Type Description
Object

An object which represents the first persistent object which matches the specified criteria. null (Nothing in Visual Basic) if there is no persistent object which matches the criteria.

Remarks

The following example uses a Parametrized Action to search for a Person by LastName, and then assigns all deferred tasks to that person.

using System.Collections;
using DevExpress.Data.Filtering;
using DevExpress.ExpressApp;
using DevExpress.ExpressApp.Actions;
using DevExpress.Persistent.Base;
using DevExpress.Persistent.Base.General;
using DevExpress.Persistent.BaseImpl;
// ...
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, true);
        if(person != null) {
            CriteriaOperator taskCriteria = CriteriaOperator.Parse("[Status] = ?", TaskStatus.Deferred);
            IList tasks = objectSpace.GetObjects(
                typeof(MainDemo.Module.BusinessObjects.DemoTask), taskCriteria);
            foreach(MainDemo.Module.BusinessObjects.DemoTask task in tasks) {
                task.AssignedTo = person;
            }
        }
    }
}

When implementing the IObjectSpace interface in the BaseObjectSpace class' descendant, you should override the FindObject(Type objectType, CriteriaOperator criteria, bool inTransaction) method. All other FindObject method overloads call this method.

See Also