This document describes the PX1035 diagnostic.
Code | Short Description | Type | Code Fix |
---|---|---|---|
PX1035 | The DAC has multiple key declarations that use the same set of fields | Warning (ISV Level 3: Informational) | Available |
A DAC should not have multiple primary, foreign, or unique key declarations that include the same fields. The diagnostic does not check abstract DACs.
To fix the issue, you should remove all primary, foreign, or unique key declarations with same sets of fields except one.
The code fix removes all primary, foreign, or unique key declarations with the same set of fields except the one for which the code fix was selected.
An example of a DAC with multiple primary key declarations that use the same set of fields is shown in the following code.
[PXCacheName("Sales Order")]
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);
}
public class PK1 : PrimaryKeyOf<SOOrder>.By<orderType, orderNbr>
{
public static SOOrder Find(PXGraph graph, string orderType, string orderNbr) => FindBy(graph, orderType, orderNbr);
}
public class PK2 : PrimaryKeyOf<SOOrder>.By<orderType, orderNbr>
{
public static SOOrder Find(PXGraph graph, string orderType, string orderNbr) => FindBy(graph, orderType, orderNbr);
}
[PXDBString(IsKey = true, InputMask = "")]
[PXDefault]
[PXUIField(DisplayName = "Order Type")]
public string OrderType { get; set; }
public abstract class orderType : IBqlField { }
[PXDBString(IsKey = true, InputMask = "")]
[PXDefault]
[PXUIField(DisplayName = "Order Nbr.")]
public string OrderNbr { get; set; }
public abstract class orderNbr : IBqlField { }
[PXStringList(new[] { "N", "O" }, new[] { "New", "Open" })]
[PXDBString]
[PXUIField(DisplayName = "Status")]
public string Status { get; set; }
public abstract class status : IBqlField { }
[PXDBTimestamp]
public virtual byte[] tstamp { get; set; }
public abstract class Tstamp : IBqlField { }
}
An example of a DAC with a fixed primary key declaration is shown in the following code.
[PXCacheName("SO Order")]
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);
}
[PXDBString(IsKey = true, InputMask = "")]
[PXDefault]
[PXUIField(DisplayName = "Order Type")]
public string OrderType { get; set; }
public abstract class orderType : IBqlField { }
[PXDBString(IsKey = true, InputMask = "")]
[PXDefault]
[PXUIField(DisplayName = "Order Nbr.")]
public string OrderNbr { get; set; }
public abstract class orderNbr : IBqlField { }
[PXStringList(new[] { "N", "O" }, new[] { "New", "Open" })]
[PXDBString]
[PXUIField(DisplayName = "Status")]
public string Status { get; set; }
public abstract class status : IBqlField { }
[PXDBTimestamp]
public virtual byte[] tstamp { get; set; }
public abstract class Tstamp : IBqlField { }
}