This document describes the PX1085 diagnostic.
| Code | Short Description | Type | Code Fix |
|---|---|---|---|
| PX1085 | BQL statements and other database queries should not be executed during the PXGraph initialization. |
Warning (ISV Level 1: Significant) | Unavailable |
BQL statements and other database queries (such as PXDatabase.Select) should not be executed during the PXGraph initialization. The execution of database queries during the PXGraph initialization slows the performance of the application.
The following code elements are considered to be a part of the graph initialization:
- The
PXGraphandPXGraphExtensionconstructors - The
Initializemethod overridden inPXGraphExtension - The
Initializemethod ofPXGraphthat implements thePX.Data.DependencyInjection.IGraphWithInitializationinterface - The
Configuremethod overridden inPXGraphandPXGraphExtension
To address the warning, you should remove the execution of the database query from PXGraph initialization and rework the related business logic.
This diagnostic is displayed only if the Enable additional diagnostics for ISV Solution Certification option (in Tools > Options > Acuminator > Code Analysis) is set to True.
public class BranchMaintExtension : PXGraphExtension<BranchMaint>
{
public override void Initialize()
{
List<string> values = new List<string>();
List<string> labels = new List<string>();
foreach (PRComboList item in PXSelect<PRComboList, //The PX1085 error is displayed for this line.
Where<PRComboList.prVariableName, Equal<Required<PRComboList.prVariableName>>>>
.Select(Base, "PrStateCode"))
{
values.Add(item.PrValueType);
labels.Add(item.PrValueName);
}
}
}