Skip to main content
Answer

What is the purpose of the first parameter of PXGraph when making PXSelect calls?

  • September 21, 2022
  • 3 replies
  • 365 views

Forum|alt.badge.img+7

As I wrap my brain further around the framework I’m starting to ask myself questions on the ‘why’ I am coding things the way that I’ve coding so I get better at all of this.

I’m not entirely certain what the first graph parameter of a PXSelect is being used for. I think I’ve read somewhere that I shouldn’t generate a generic PXGraph for the first parameter.

So, in this example, I can see how my soOrderEntry graph becomes the source of the query so that it will return the lines from the soOrderEntry record that it currently holds.

var lines = SelectFrom<SOLine>.
Where<SOLine.orderType.IsEqual<SOOrder.orderType.FromCurrent>
.And<SOLine.orderNbr.IsEqual<SOOrder.orderNbr.FromCurrent>>>
.OrderBy<Desc<SOLine.lineNbr>>
.View.Select(soOrderEntry);

But, in the case where I need to find, say, a warehouse code and I use:

INSite iNSite = INSite.PK.Find(this, siteID);

I’ve used ‘this’ because this code resides within a Graph Extension. This is a stand alone query so my question is, what is the purpose/relevance to what graph that I use for the INSite lookup?

Is it in relation to the cache of ‘this’ so that a subsequent call would potentially be more efficient?

Is there a disadvantage or an unintended consequence to calling:

INSite iNSite = INSite.PK.Find(soOrderEntry, siteID);

 

Best answer by Leonardo Justiniano

Hi @ddunn 

Any BQL query run in the context of a Graph. When you create a graph for a screen you usually pass the current graph context (this). If You are extending an existing graph you have to pass the original graph (Base, Base1,...) 

 

3 replies

Leonardo Justiniano
Jr Varsity II
Forum|alt.badge.img+4

Hi @ddunn 

Any BQL query run in the context of a Graph. When you create a graph for a screen you usually pass the current graph context (this). If You are extending an existing graph you have to pass the original graph (Base, Base1,...) 

 


Forum|alt.badge.img+7
  • Author
  • Captain II
  • September 21, 2022

Thank you!


Stéphane Bélanger
Freshman II
Forum|alt.badge.img

You will notice that sometimes you will use static methods (for which you need to pass the PXGraph instance).  Other time, you will use instance values (such as your PXSelect queries), then you won’t need to pass it since it is already connected with the Graph.  Anyhow, like Leonardo said, all queries run in conjonction with the PXGraph instance since the data is stored in PXCache instances inside of the PXGraph.