我已将客户位置添加到全文实体索引中,但无法弄清楚如何从位置获取地址行 1以成为全文索引的一部分并显示在结果中。
1 回答
要包含链接实体的字段(与数据输入屏幕上的顶级实体一对一的关系),需要指定应与 PXSelectorAttribute 一起使用的顶级实体字段来检索关联实体。在充当链接实体之间桥梁的顶级实体字段之后,您将指定二级实体的字段,这些字段应包含在全文索引中和/或显示在结果中。请记住,只有用 PXSelectorAttribute 或 PXDimensionSelectorAttribute 修饰的顶级实体字段才能充当链接实体之间的桥梁。
例如,要将地址DAC 中的字段包含到客户位置全文实体索引中,您必须在列出地址DAC 中的字段之前添加位置DAC中的DefAddressID字段:
public partial class Location : PX.Data.IBqlTable, IPaymentTypeDetailMaster, ILocation
{
...
public abstract class defAddressID : IBqlField { }
[PXDBInt()]
[PXDBChildIdentity(typeof(Address.addressID))]
[PXUIField(DisplayName = "Default Address", Visibility = PXUIVisibility.Invisible)]
[PXSelector(typeof(Search<Address.addressID>), DirtyRead = true)]
public virtual int? DefAddressID { get; set; }
...
}
以下代码片段中的CustomerLocation DAC 可以作为用于将客户位置添加到全文实体索引的自定义 DAC 的完美示例:
[Serializable]
[PXCacheName("Customer Location")]
[PXBreakInheritance]
public partial class CustomerLocation : SelectedCustomerLocation
{
public new abstract class bAccountID : IBqlField { }
[Customer(typeof(Search<Customer.bAccountID,
Where<Customer.type, Equal<BAccountType.customerType>,
Or<Customer.type, Equal<BAccountType.prospectType>,
Or<Customer.type, Equal<BAccountType.combinedType>>>>>),
IsKey = true)]
public override int? BAccountID { get; set; }
public new abstract class locationCD : IBqlField { }
public new abstract class descr : IBqlField { }
public new abstract class defAddressID : IBqlField { }
public new abstract class locType : IBqlField { }
public new abstract class noteID : IBqlField { }
[PXNote()]
[PXSearchable(SM.SearchCategory.CR, "{1} {2}: {3}",
new Type[] {
typeof(CustomerLocation.bAccountID),
typeof(Customer.acctCD),
typeof(CustomerLocation.locationCD),
typeof(CustomerLocation.descr) },
new Type[] {
typeof(CustomerLocation.bAccountID),
typeof(Customer.acctCD),
typeof(CustomerLocation.locationCD),
typeof(CustomerLocation.descr),
typeof(CustomerLocation.defAddressID),
typeof(Address.addressLine1),
typeof(Address.addressLine2),
typeof(Address.city),
typeof(Address.countryID) },
Line1Format = "{0} {2}",
Line1Fields = new Type[] {
typeof(CustomerLocation.descr),
typeof(CustomerLocation.defAddressID),
typeof(Address.addressLine1) },
Line2Format = "{1}",
Line2Fields = new Type[] {
typeof(CustomerLocation.defAddressID),
typeof(Address.addressLine2) },
WhereConstraint =
typeof(Where<CustomerLocation.locType, Equal<LocTypeList.customerLoc>,
Or<CustomerLocation.locType, Equal<LocTypeList.combinedLoc>>>),
MatchWithJoin = typeof(InnerJoin<Customer,
On<Customer.bAccountID, Equal<CustomerLocation.bAccountID>>>),
SelectForFastIndexing = typeof(Select2<CustomerLocation,
InnerJoin<Customer,
On<CustomerLocation.bAccountID, Equal<Customer.bAccountID>>>>)
)]
public override Guid? NoteID { get; set; }
}
除了用于包含从地址DAC 到全文实体索引的字段的 DefAddressID 字段之外,CustomerLocation还利用附加到BAccountID字段的CustomerAttribute来包含客户的自然应用程序AcctCD键,而不是代理数据库级BAccountID键. 最后要提到的是PXBreakInheritanceAttribute需要在重建全文实体索引屏幕上防止初始化与基本 DAC 对应的 PXCache 对象时,系统会生成全文实体索引使用的实体列表。