我有一个加入BAccount表的BQL查询,但是当我查看SQL事件探查器时,它正在查询供应商表,我试图检索的对象不是供应商。这是我为SOLine表中的客户字段添加的自定义选择器。使用的所有字段和表都是基本的Acumatica字段和表。这是我的BQL代码:
[PXDBString(50, IsUnicode = true)]
[PXUIField(DisplayName = "Default Specification")]
[PXSelector(typeof(Search5<UploadFileRevision.comment,
InnerJoin<UploadFile, On<UploadFile.fileID, Equal<UploadFileRevision.fileID>>,
InnerJoin<NoteDoc, On<NoteDoc.fileID, Equal<UploadFile.fileID>>,
InnerJoin<BAccount, On<BAccount.noteID, Equal<NoteDoc.noteID>>,
InnerJoin<Customer, On<Customer.bAccountID, Equal<BAccount.bAccountID>>
>>>>, Where<Customer.bAccountID, Equal<Current<SOOrder.customerID>>>,
Aggregate<GroupBy<UploadFileRevision.comment>>>),
typeof(UploadFileRevision.comment), typeof(UploadFile.name),
typeof(UploadFile.fileID))]
代码在SQL事件探查器中转换为:
exec sp_executesql N'SELECT TOP (12) MAX([UploadFileRevision].[FileID]),
MAX([UploadFileRevision].[FileRevisionID]), NULL, MAX([UploadFileRevision].
[BlobHandler]), [UploadFileRevision].[Comment],
MAX([UploadFileRevision].[Size]), MAX([UploadFileRevision].[OriginalName]),
MAX([UploadFileRevision].[OriginalTimestamp]), MAX([UploadFileRevision].
[CreatedByID]), MAX([UploadFileRevision].[CreatedDateTime]),
MAX([UploadFile].[FileID]), MAX([UploadFile].[Name]), MAX([UploadFile].
[CheckedOutComment]), CONVERT (BIT, MAX([UploadFile].[Versioned]+0)),
MAX([UploadFile].[CreatedByID]), MAX([UploadFile].[CreatedDateTime]),
MAX([UploadFile].[LastRevisionID]), MAX([UploadFile].[CheckedOutBy]),
MAX([UploadFile].[PrimaryPageID]), MAX([UploadFile].[PrimaryScreenID]),
MAX([UploadFile].[tstamp]), CONVERT (BIT, MAX([UploadFile].[IsHidden]+0)),
CONVERT (BIT, MAX([UploadFile].[Synchronizable]+0)), MAX([UploadFile].
[SourceType]), MAX([UploadFile].[SourceUri]), MAX([UploadFile].
[SourceLogin]), MAX([UploadFile].[SourcePassword]), CONVERT (BIT,
MAX([UploadFile].[SourceIsFolder]+0)), MAX([UploadFile].[SourceMask]),
MAX([UploadFile].[SourceNamingFormat]), MAX([UploadFile].
[SourceLastImportDate]), MAX([UploadFile].[SourceLastExportDate]), CONVERT
(BIT,
MAX([UploadFile].[IsPublic]+0)), MAX([UploadFile].[NoteID]), NULL, NULL,
NULL, MAX([NoteDoc].[NoteID]), MAX([NoteDoc].[FileID]),
MAX([BAccount_BAccount].[BAccountID]), NULL, MAX([BAccount_BAccount].
[AcctReferenceNbr]),
MAX([BAccount_BAccount].[ParentBAccountID]), CONVERT (BIT,
MAX([BAccount_BAccount].[ConsolidateToParent]+0)), MAX([BAccount_BAccount].
[ConsolidatingBAccountID]), MAX([BAccount_BAccount].[DefAddressID]),
MAX([BAccount_BAccount].[DefContactID]), MAX([BAccount_BAccount].
[DefLocationID]), MAX([BAccount_BAccount].[TaxRegistrationID]),
MAX([BAccount_BAccount].[WorkgroupID]), MAX([BAccount_BAccount].[tstamp]),
MAX([BAccount_BAccount].[CreatedByID]), MAX([BAccount_BAccount].
[CreatedByScreenID]), MAX([BAccount_BAccount].[CreatedDateTime]),
MAX([BAccount_BAccount].[LastModifiedByID]), MAX([BAccount_BAccount].
[LastModifiedByScreenID]), MAX([BAccount_BAccount].[LastModifiedDateTime]),
MAX([BAccount_BAccount].[AcctCD]), MAX([BAccount_BAccount].[AcctName]),
MAX([BAccount_BAccount].[Type]), MAX([BAccount_Vendor].[VendorClassID]),
MAX([BAccount_Vendor].[TermsID]), MAX([BAccount_Vendor].[DefPOAddressID]),
MAX([BAccount_Vendor].[CuryID]), MAX([BAccount_Vendor].[CuryRateTypeID]),
MAX([BAccount_Vendor].[PriceListCuryID]), MAX([BAccount_Vendor].
[DefaultUOM]), CONVERT (BIT, MAX([BAccount_Vendor].[AllowOverrideCury]+0)),
CONVERT (BIT, MAX([BAccount_Vendor].[AllowOverrideRate]+0)),
MAX([BAccount_Vendor].[DiscTakenAcctID]), MAX([BAccount_Vendor].
[DiscTakenSubID]), MAX([BAccount_Vendor].[PrepaymentAcctID]),
MAX([BAccount_Vendor].[PrepaymentSubID]), MAX([BAccount_Vendor].
[POAccrualAcctID]), MAX([BAccount_Vendor].[POAccrualSubID]),
MAX([BAccount_Vendor].[PrebookAcctID]), MAX([BAccount_Vendor].
[PrebookSubID]), CONVERT (BIT, MAX([BAccount_Vendor].[PayToParent]+0)),
MAX([BAccount_Vendor].[BaseRemitContactID]), MAX([BAccount_BAccount].
[TaxZoneID]), MAX([BAccount_BAccount].[Status]), CONVERT (BIT,
MAX([BAccount_Vendor].[Vendor1099]+0)), MAX([BAccount_Vendor].[Box1099]),
CONVERT (BIT, MAX([BAccount_Vendor].[FATCA]+0)), CONVERT (BIT,
MAX([BAccount_Vendor].[TaxAgency]+0)), CONVERT (BIT, MAX([BAccount_Vendor].
[UpdClosedTaxPeriods]+0)), MAX([BAccount_Vendor].[TaxReportPrecision]),
MAX([BAccount_Vendor].[TaxReportRounding]), CONVERT (BIT,
MAX([BAccount_Vendor].[TaxUseVendorCurPrecision]+0)), CONVERT (BIT,
MAX([BAccount_Vendor].[TaxReportFinPeriod]+0)), MAX([BAccount_Vendor].
[TaxPeriodType]), CONVERT (BIT, MAX([BAccount_Vendor].
[EnableTaxStartDate]+0)), MAX([BAccount_Vendor].[TaxYearStartDate]),
MAX([BAccount_Vendor].[SalesTaxAcctID]), MAX([BAccount_Vendor].
[SalesTaxSubID]), MAX([BAccount_Vendor].[PurchTaxAcctID]),
MAX([BAccount_Vendor].[PurchTaxSubID]), MAX([BAccount_Vendor].
[TaxExpenseAcctID]), MAX([BAccount_Vendor].[TaxExpenseSubID]), NULL,
MAX([BAccount_BAccount].[OwnerID]), MAX([BAccount_BAccount].[NoteID]), NULL,
NULL, NULL, CONVERT (BIT,
MAX([BAccount_Vendor].[LandedCostVendor]+0)), CONVERT (BIT,
MAX([BAccount_Vendor].[IsLaborUnion]+0)), MAX([BAccount_Vendor].
[LineDiscountTarget]), CONVERT (BIT, MAX([BAccount_Vendor].
[IgnoreConfiguredDiscounts]+0)), CONVERT
(BIT, MAX([BAccount_Vendor].[ForeignEntity]+0)), MAX([BAccount_Vendor].
[LocaleName]), MAX([BAccount_Vendor].[SVATReversalMethod]),
MAX([BAccount_Vendor].[SVATInputTaxEntryRefNbr]),
MAX([BAccount_Vendor].[SVATOutputTaxEntryRefNbr]), MAX([BAccount_Vendor].
[SVATTaxInvoiceNumberingID]), MAX([Customer_BAccount].[BAccountID]),
MAX([Customer_BAccount].[AcctReferenceNbr]),
MAX([Customer_BAccount].[ParentBAccountID]), CONVERT (BIT,
MAX([Customer_BAccount].[ConsolidateToParent]+0)), MAX([Customer_BAccount].
[ConsolidatingBAccountID]), MAX([Customer_BAccount].[DefAddressID]),
MAX([Customer_BAccount].[DefContactID]), MAX([Customer_BAccount].
[DefLocationID]), MAX([Customer_BAccount].[TaxRegistrationID]),
MAX([Customer_BAccount].[WorkgroupID]), MAX([Customer_BAccount].[OwnerID]),
MAX([Customer_BAccount].[tstamp]), MAX([Customer_BAccount].[CreatedByID]),
MAX([Customer_BAccount].[CreatedByScreenID]), MAX([Customer_BAccount].
[CreatedDateTime]), MAX([Customer_BAccount].[LastModifiedByID]),
MAX([Customer_BAccount].[LastModifiedByScreenID]), MAX([Customer_BAccount].
[LastModifiedDateTime]), MAX([Customer_BAccount].[AcctCD]),
MAX([Customer_BAccount].[Type]), NULL, CONVERT (BIT,
MAX([Customer_Customer].[ConsolidateStatements]+0)), CONVERT (BIT,
MAX([Customer_Customer].[SharedCreditPolicy]+0)), MAX([Customer_Customer].
[StatementCustomerID]), MAX([Customer_Customer].[SharedCreditCustomerID]),
MAX([Customer_Customer].[CustomerClassID]), MAX([Customer_Customer].
[LanguageID]), MAX([Customer_Customer].[DefSOAddressID]),
MAX([Customer_Customer].[DefBillAddressID]), MAX([Customer_Customer].
[DefBillContactID]),
MAX([Customer_Customer].[BaseBillContactID]), MAX([Customer_BAccount].
[TaxZoneID]), MAX([Customer_Customer].[TermsID]), MAX([Customer_Customer].
[CuryID]), MAX([Customer_Customer].[CuryRateTypeID]), CONVERT (BIT,
MAX([Customer_Customer].[AllowOverrideCury]+0)), CONVERT (BIT,
MAX([Customer_Customer].[AllowOverrideRate]+0)), MAX([Customer_Customer].
[DiscTakenAcctID]), MAX([Customer_Customer].[DiscTakenSubID]),
MAX([Customer_Customer].[PrepaymentAcctID]), MAX([Customer_Customer].
[PrepaymentSubID]), MAX([Customer_Customer].[COGSAcctID]),
MAX([Customer_Customer].[COGSSubID]), CONVERT (BIT, MAX([Customer_Customer].
[AutoApplyPayments]+0)), CONVERT (BIT, MAX([Customer_Customer].
[PrintStatements]+0)), CONVERT (BIT, MAX([Customer_Customer].
[PrintCuryStatements]+0)), CONVERT (BIT, MAX([Customer_Customer].
[SendStatementByEmail]+0)), MAX([Customer_Customer].[CreditRule]),
MAX([Customer_Customer].[CreditLimit]), MAX([Customer_Customer].
[CreditDaysPastDue]), MAX([Customer_Customer].[StatementType]),
MAX([Customer_Customer].[StatementCycleId]), MAX([Customer_Customer].
[StatementLastDate]), CONVERT (BIT, MAX([Customer_Customer].
[SmallBalanceAllow]+0)), MAX([Customer_Customer].[SmallBalanceLimit]),
CONVERT (BIT, MAX([Customer_Customer].[FinChargeApply]+0)), CONVERT (BIT,
MAX([Customer_Customer].[PayToParent]+0)), MAX([Customer_BAccount].
[Status]), MAX([Customer_BAccount].[AcctName]), NULL,
MAX([Customer_Customer].[DefPaymentMethodID]), MAX([Customer_Customer].
[CCProcessingID]), MAX([Customer_Customer].[DefPMInstanceID]), CONVERT (BIT,
MAX([Customer_Customer].[PrintInvoices]+0)), CONVERT (BIT,
MAX([Customer_Customer].[MailInvoices]+0)), MAX([Customer_BAccount].
[NoteID]), NULL, NULL, NULL, CONVERT (BIT, MAX([Customer_Customer].
[PrintDunningLetters]+0)), CONVERT (BIT, MAX([Customer_Customer].
[MailDunningLetters]+0)), MAX([Customer_Customer].[LocaleName]),
MAX([Customer_Customer].[UsrCertType])
FROM [UploadFileRevision] [UploadFileRevision]
INNER JOIN [UploadFile] [UploadFile] ON [UploadFile].CompanyID IN (1, 3) AND
32 = SUBSTRING([UploadFile].CompanyMask, 1, 1) & 32 AND [UploadFile].
[FileID] = [UploadFileRevision].[FileID]
INNER JOIN [NoteDoc] [NoteDoc] ON [NoteDoc].CompanyID IN (1, 3) AND 32 =
SUBSTRING([NoteDoc].CompanyMask, 1, 1) & 32 AND [NoteDoc].[FileID] =
[UploadFile].[FileID]
INNER JOIN (
[Vendor] BAccount_Vendor
INNER JOIN [BAccount] BAccount_BAccount ON [BAccount_BAccount].CompanyID = 3
AND [BAccount_BAccount].[DeletedDatabaseRecord] = 0
) ON [BAccount_BAccount].[NoteID] = [NoteDoc].[NoteID] AND
[BAccount_Vendor].CompanyID = 3 AND [BAccount_Vendor].
[DeletedDatabaseRecord] = 0 AND [BAccount_Vendor].[BAccountID] =
[BAccount_BAccount].[BAccountID]
INNER JOIN (
[Customer] Customer_Customer
INNER JOIN [BAccount] Customer_BAccount ON [Customer_BAccount].CompanyID = 3
AND [Customer_BAccount].[DeletedDatabaseRecord] = 0
) ON [Customer_BAccount].[BAccountID] = [BAccount_BAccount].[BAccountID] AND
[Customer_Customer].CompanyID = 3 AND [Customer_Customer].
[DeletedDatabaseRecord] = 0 AND [Customer_Customer].[BAccountID] =
[Customer_BAccount].[BAccountID]
WHERE [UploadFileRevision].CompanyID IN (1, 3) AND 32 =
SUBSTRING([UploadFileRevision].CompanyMask, 1, 1) & 32 AND
[Customer_BAccount].[BAccountID] = @P0
GROUP BY [UploadFileRevision].[Comment]
ORDER BY [UploadFileRevision].[Comment], MAX([UploadFileRevision].[FileID]),
MAX([UploadFileRevision].[FileRevisionID]) OPTION(OPTIMIZE FOR UNKNOWN) /*
SO.30.10.00 */',N'@P0 int',@P0=8934
您可以看到,当它加入BAccount时,它使用[Vender] BAccount_Vendor,但我的BQL代码不包含任何涉及供应商的内容。我甚至在客户表中添加了冗余连接,但它什么也没做。我是否错过了强迫它查看BAccount表而不是供应商的内容?
答案 0 :(得分:1)
尝试用BAccountR或BAccount2替换BAccount。在BAccount缓存之前,必须在BLC的Caches集合中为Vendor DAC初始化缓存 - 这通常会导致BQL转换为不同数据库表的SQL查询。
要检查初始化缓存的顺序,在VS中的立即窗口中,您可以为自定义BLC执行this.Caches
或为BLC扩展执行Base.Caches
。我很确定你会在BAccount之前初始化供应商缓存。
不幸的是,我尝试重现错误&#34;多部分标识符&#34; BAccount2.BAccountID&#34;无法受约束的#34;没有成功。这是我在最后使用的自定义SOLine字段声明:
public class SOLineExt : PXCacheExtension<SOLine>
{
public abstract class usrComment : IBqlField { }
[PXDBString(50, IsUnicode = true)]
[PXUIField(DisplayName = "Default Specification")]
[PXSelector(
typeof(Search5<UploadFileRevision.comment,
InnerJoin<UploadFile,
On<UploadFile.fileID, Equal<UploadFileRevision.fileID>>,
InnerJoin<NoteDoc,
On<NoteDoc.fileID, Equal<UploadFile.fileID>>,
InnerJoin<BAccountR,
On<BAccountR.noteID, Equal<NoteDoc.noteID>>>>>,
Where<BAccountR.bAccountID, Equal<Current<SOOrder.customerID>>>,
Aggregate<GroupBy<UploadFileRevision.comment>>>),
typeof(UploadFileRevision.comment), typeof(UploadFile.name),
typeof(UploadFile.fileID))]
public string UsrComment { get; set; }
}
我错过了什么或做错了吗?