This document describes the PX1033 diagnostic.
Code | Short Description | Type | Code Fix |
---|---|---|---|
PX1033 | The DAC does not have an explicit primary key declaration | Warning (ISV Level 3: Informational) | Available |
You can define a primary key field in a DAC. The diagnostic suggests adding a primary key definition to a DAC.
The warning is shown only for DACs that have an attribute derived from the PXCacheName
attribute, or an attribute derived from the PXPrimaryGraphBase
attribute such as PXPrimaryGraphAttribute
.
The diagnostic does not check abstract DACs and DACs which have only unbound DAC properties (fully-unbound DACs used for custom popups and filters for inquiry forms).
To fix the issue, add the PK class to the DAC.
The code fix generates a primary key and the 'Find' method which allows to easily find DAC row by providing values composing primary key.
[PXCacheName(Messages.SOOrder)]
public class SOOrder : PXBqlTable, IBqlTable
{
#region OrderType
public abstract class orderType : PX.Data.BQL.BqlString.Field<orderType> { }
[PXDBString(2, IsKey = true, IsFixed = true, InputMask = ">aa")]
...
public virtual String OrderType {get; set; }
#endregion
#region OrderNbr
[PXDBString(IsKey = true, InputMask = "")]
[PXDefault]
[PXUIField(DisplayName = "Order Nbr.")]
public string OrderNbr { get; set; }
public abstract class orderNbr : PX.Data.BQL.BqlString.Field<orderNbr > { }
#endregion
}
[PXCacheName(Messages.SOOrder)]
public class SOOrder : PXBqlTable, IBqlTable
{
public class PK : PrimaryKeyOf<SOOrder>.By<orderType, orderNbr>
{
public static SOOrder Find(PXGraph graph, string orderType, string orderNbr) => FindBy(graph, orderType, orderNbr);
}
#region OrderType
public abstract class orderType : PX.Data.BQL.BqlString.Field<orderType> { }
[PXDBString(2, IsKey = true, IsFixed = true, InputMask = ">aa")]
...
public virtual String OrderType {get; set; }
#endregion
#region OrderNbr
[PXDBString(IsKey = true, InputMask = "")]
[PXDefault]
[PXUIField(DisplayName = "Order Nbr.")]
public string OrderNbr { get; set; }
public abstract class orderNbr : PX.Data.BQL.BqlString.Field<orderNbr > { }
#endregion
}
Primary Key
To Define a Primary Key
PXCacheNameAttribute Class
PXPrimaryGraphAttribute Class