Skip to main content
A newer version of this page is available. .
All docs
V20.2
.NET Framework 4.5.2+

NonPersistentObjectSpace.CustomGetObjectsQuery Event

Occurs when the GetObjectsQuery<T>(Boolean) method is executed.

Namespace: DevExpress.ExpressApp

Assembly: DevExpress.ExpressApp.v20.2.dll

NuGet Package: DevExpress.ExpressApp

Declaration

public event EventHandler<CustomGetObjectsQueryEventArgs> CustomGetObjectsQuery

Event Data

The CustomGetObjectsQuery event's data class is DevExpress.ExpressApp.CustomGetObjectsQueryEventArgs.

Remarks

Handle this event to pass a custom strongly-typed query of non-persistent objects to the GetObjectsQuery<T>(Boolean) method. The following example shows how to handle this event in the platform-agnostic Module (the MySolution.Module project):

using DevExpress.ExpressApp;
using System.Collections.Generic;
using System.Linq;
// ...
public sealed partial class MySolutionModule : ModuleBase {
    // ...
    public override void Setup(XafApplication application) {
        base.Setup(application);
        application.ObjectSpaceCreated += Application_ObjectSpaceCreated;
    }
    private void Application_ObjectSpaceCreated(object sender, ObjectSpaceCreatedEventArgs e) {
        NonPersistentObjectSpace nonPersistentObjectSpace = e.ObjectSpace as NonPersistentObjectSpace;
        if (nonPersistentObjectSpace != null) {
            nonPersistentObjectSpace.CustomGetObjectsQuery += NonPersistentObjectSpace_CustomGetObjectsQuery;
            //...
        }
    }
    List<Article> articles;
    // ...
    private void NonPersistentObjectSpace_CustomGetObjectsQuery(object sender, CustomGetObjectsQueryEventArgs e) {
        if (typeof(Article).IsAssignableFrom(e.ObjectType)) {
            e.Queryable = articles.AsQueryable();
        }
    }
}
See Also