I thought that the only time a View gets populated with records if is you make a call to “View.Select()” or if the View references a “fromcurrent”.
In the following simplified example, I have a graph with a view. When I run a SelectFrom statement, without referencing the view, the view gets populated with records and I don’t know why.
PXGraph joesGraph
in the joesGraph there is a view:
public SelectFrom<ICSARAddressSQL>.View JoesView;
In my method, I use a fluent BQL to fetch records in the ICSARAddressSQL table (which is actually a SQL View) where the customerAddressID is equal to “item” where item is the CustomerAddressID I am fetching.
Then I check to see if that record is in the joesView cache. If it is ALREADY in the cache I update the cache record. Otherwise I add it to the cache in the ELSE section.
foreach (ICSARAddressSQL record in SelectFrom<ICSARAddressSQL>.Where<ICSARAddressSQL.customerAddressID.IsEqual<@P.AsInt>>.View.Select(joesGraph, item))
{
ICSARAddressSQL cached = joesGraph.JoesView.Locate(record);
if (cached != null)
{ //do some work here
graph.JoesView.Update(cached);
}
else
{ //do some work here
graph.JoesView.Update(record);
}
}
As soon as the SelectFrom is executed, the JoesView view is filled with the records. There is no direct reference to the View in that call. How does the view get filled with records from the SelectFrom? I’m not calling graph.JoesView.Select().
Is this because the graph is automatically associating the ICSARAddressSQL table with the the SelectFrom statement because the source table is the same?
I would think that the SelectFrom is “not connected” to the view because it is not referenced directly.
This is not a problem, I just want to know if this is what you folks know should be happening. This unexpected behavior would actually simplify my code since the View is already populated and I don’t need to check if the record has already been cached. This is to help me understand some underlying logic in Acumatica I did not know.