【发布时间】:2020-12-04 09:33:41
【问题描述】:
什么属性可以用来允许唯一值, 我们使用 [PXUniqueCheck(typeof(Name))] 但是如果使用 List 视图并且使用相同的名称更新记录,它允许相同的名称值
更多详情 - 嗨,列标记为 IsKey = True 的名称,我的视图是 ListView,有 2 个字段名称和描述,其中名称具有 IsKey =True 和另一个列 ID 具有 DBIdentity 属性。所以我认为DAC,UI添加行为一切正常 - 添加现有值时,它会使用新添加的值描述更新旧行,因为名称相同。更新行为 - 将名称列更改为与其他相同的值,然后它允许有 2 行具有相同的键,但两行在 UI 上显示相同的描述,但在 DB 中有 2 行具有相同的名称值和不同的描述
DAC -
[System.SerializableAttribute()]
[PXPrimaryGraph(typeof(TestCategoryMaint))]
public class TestCategory : PX.Data.IBqlTable
{
#region TestCategoryID
public abstract class testCategoryID : PX.Data.BQL.BqlInt.Field<testCategoryID>
{
}
protected int? _TestCategoryID;
[PXDBIdentity()]
[LicenseExpiration]
[PXReferentialIntegrityCheck]
public virtual int? TestCategoryID
{
get
{
return this._TestCategoryID;
}
set
{
this._TestCategoryID = value;
}
}
#endregion
#region Name
public abstract class name : PX.Data.IBqlField
{
}
protected string _Name;
[PXDBString(50, IsKey = true, IsUnicode = true, InputMask = "")]
[PXDefault()]
[PXUIField(DisplayName = "Test Category")]
[PXCheckUnique(typeof(name))]
public virtual string Name
{
get
{
return this._Name;
}
set
{
this._Name = value;
}
}
#endregion
#region Description
public abstract class description : PX.Data.IBqlField
{
}
protected string _Description;
[PXDBString(255,IsUnicode =true)]
[PXUIField(DisplayName = "Description")]
public virtual string Description
{
get
{
return this._Description;
}
set
{
this._Description = value;
}
}
#endregion
【问题讨论】:
-
如果您想要唯一的值,您是否考虑将 IsKey 添加到您的 DAC 字段?听起来您的字段是某种类型的主键
-
Iskey 被添加到引用表中使用的标识列中,而名称是 CD 字段
-
您可以在 CD 字段上使用 IsKey,并且在其他表中仍然使用标识(无键)列作为参考。 SQL 表键可以与 DAC 键不同,这很好。
-
Dmitry,是的,名称是用 ISKey true 分配的,但仍然使用列表视图,我们可以重现具有相同名称的 2 行,方法是使用与其他行相同的名称更新现有行,然后它在 UI 上显示具有相同值的两行。