Skip to main content
All docs
V24.2
.NET Framework 4.6.2+

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

NonPersistentObjectSpace.CustomGetObjectsQuery Event

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

Namespace: DevExpress.ExpressApp

Assembly: DevExpress.ExpressApp.v24.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 Application Builder code:

File: MySolution.Blazor.Server/Startup.cs, MySolution.Win/Startup.cs, MySolution.WebApi/Startup.cs

using DevExpress.ExpressApp;
// ...
builder.ObjectSpaceProviders.Events.OnObjectSpaceCreated = context => {
    NonPersistentObjectSpace nonPersistentObjectSpace = context.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