问题
Below is extension DAC and Graph code, INRegisterKitAssemblyExt is a DAC, i have created a database table for that. i want to save usrSiteID value in INRegisterKitAssemblyExt(separate) database table. Please check how may i initialize extension DAC with INKitRegister DAC and save the value and how to use usrSiteId in UI?
[PXTable(typeof(INKitRegister.refNbr), typeof(INKitRegister.KitRevisionId))]
public class INRegisterKitAssemblyExt: PXCacheExtension<INKitRegister> {
#region RefNbr
public abstract class refNbr:PX.Data.BQL.BqlString.Field<refNbr> {
}
protected String _RefNbr;
[PXDBDefault(typeof(INKitRegister.refNbr))]
[PXDBString()]
[PXParent(typeof(Select<INKitRegister, Where<INKitRegister.refNbr, Equal<Current<refNbr>>,And<INKitRegister.kitRevisionID, Equal<Current<kitRevisionID>>>>>))]
public virtual String RefNbr {
get {
return this._RefNbr;
}
set {
this._RefNbr = value;
}
}
#endregion
#region KitRevisionID
public abstract class kitRevisionID:PX.Data.BQL.BqlString.Field<kitRevisionID> {
}
protected String _KitRevisionID;
[PXDBDefault(typeof(INKitRegister.kitRevisionID))]
[PXDBString()]
public virtual String KitRevisionID {
get {
return this._KitRevisionID;
}
set {
this._KitRevisionID = value;
}
}
#endregion
// My Fields as well as refNbr and KitRevison is also here
public virtual int? UsrQCSiteID {
get; set;
}
public abstract class usrQCSiteID:PX.Data.BQL.BqlInt.Field<usrQCSiteID> {
}
}
// Extension Graph
public class KitAssemblyEntryExt:PXGraphExtension<KitAssemblyEntry> {
}
回答1:
INRegisterKitAssemblyExt in your code example is not a DAC. DAC inherits from the IBqlTable base class.
INRegisterKitAssemblyExt in your code example is a DAC extension. DAC extensions inherits from the PXCacheExtension base class. You should never create database table for DAC extensions.
Custom fields in DAC extension will be persisted to the base DAC table automatically. The main issue here is that INKitRegister is not DAC bound to a database table. It's a Projection DAC and the INKitRegister database table does not exist.
The INKitRegister DAC projection points to the INRegister DAC:
[PXPrimaryGraph(typeof(KitAssemblyEntry))]
[PXCacheName(Messages.INKit)]
[PXProjection(typeof(Select2<INRegister, InnerJoin<INTran, On<INRegister.FK.KitTran>>>), Persistent=true)]
[Serializable]
public partial class INKitRegister : IBqlTable, ILSPrimary
You should create an extension on the INRegister DAC instead of INKitRegister because INRegister is bounded to an actual database table of the same name:
public class INRegisterKitAssemblyExt: PXCacheExtension<INRegister>
来源:https://stackoverflow.com/questions/61642436/how-to-work-with-extension-table-with-projection-inkitassembly-projection-class