Is it possible to have a Graph and page utilize an completely unbound DAC?
When attempting this currently in 4.20 I'm receiving the following error message:
Incorrect syntax near the keyword 'FROM'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Data.SqlClient.SqlException: Incorrect syntax near the keyword 'FROM'.
If I create a table in the database and change my DAC fields from say PXInt to PXDBInt, then the page loads however for what I'm attempting to do I have no need to actually store the data.
DAC sample:
namespace Acumatica1
{
[PXPrimaryGraph(typeof(UnboundDataTest))]
[System.SerializableAttribute()]
public class UnboundDAC : PX.Data.IBqlTable
{
public abstract class unboundKey : PX.Data.IBqlField
{
}
protected int _UnboundKey;
[PXInt(IsKey = true)]
[PXUIField(Visible = false)]
public virtual int UnboundKey
{
get
{
return this._UnboundKey;
}
set
{
this._UnboundKey = value;
}
}
#region UnboundText
public abstract class unboundText : PX.Data.IBqlField
{
}
protected string _UnboundText;
[PXString]
[PXUIField(DisplayName = "Text")]
public virtual string UnboundText
{
get
{
return this._UnboundText;
}
set
{
this._UnboundText = value;
}
}
#endregion
}
}
Graph Sample:
public class UnboundDataTest: PXGraph<UnboundDataTest>
{
public PXSelect<UnboundDAC> UnboundInfo;
}
To take control of the select process, you need to create a delegate that will be invoked when the UnboundInfo view is selected:
Inside this delegate, you are free to use whatever mechanism you want to retrieve the record(s) that should be returned by this unbound select. For example, you can create one or more objects on the fly and return them:
If you somehow need to allow the user to edit the values in your UnboundDAC, you could leverage the Cache, and insert the records in the cache the first time the view is selected:
Finally, you could take a look at the internal implementation of PXFilter; PXFilter is a specialized PXSelect that doesn't actually select anything from the database; all it does it insert one row in the cache the first time it is selected, and prevent persisting of this row. You could use a similar technique to create a PXUnboundSelect class that could be reused easily in multiple graphs.