簡體   English   中英

當我使用 IQueryable 時,.NET Core 中的 Take 和 Skip 分頁返回不正確的記錄

[英]Pagination with Take and Skip in .NET Core returns incorrect records when I use IQueryable

我有一個IQueryable查詢。

在應用分頁之前,我一直在使用這段代碼:

query = pageSize != -1 ? 
                query.Skip(pageNumber * pageSize).Take(pageSize) : 
                query; 

一切正常,記錄返回真實。 所以我在上面一行之前和之后添加了這段代碼,如你所見, pageNumber = 0pageSize = 10 由於堆棧,我不得不刪除部分查詢

var sqlBefore = query.ToQueryString();

query = pageSize != -1 ? 
            query.Skip(pageNumber * pageSize).Take(pageSize) : 
            query;

var sqlAfter = query.ToQueryString();

當我在 SQL 服務器中執行sqlBefore查詢時,我得到 1675 條記錄,當我執行sqlAfter時,我得到 6 條記錄。 我不知道為什么。

這里是sqlBeforesqlAfter變量,可以看到在sqlAfter中添加了這一行

OFFSET @__p_5 ROWS FETCH NEXT @__p_6 ROWS ONLY

我希望記錄應該是 10 條記錄,但它返回 6 條記錄。

SQL之前:

DECLARE @__input_ReferralType_1 smallint = CAST(3 AS smallint);
DECLARE @__GetUserId_3 nvarchar(450) = N'a4bf84af-0758-4b08-8c1c-240ca0892afa';
DECLARE @__input_BranchId_4 int = 12;

SELECT [p].[Id], [p].[Amount], [p].[AttachmentId], [p].[BranchId], [p].[CostCenterId1], [p].[CostCenterId2], [p].[CreationTime], [p].[CreatorUserId], [p].[DOB], [p].[DeleterUserId], [p].[DeletionTime], [p].[DepositToCustomerBankAccountId], [p].[Description], [p].[FormalDateTime], [p].[Guid], [p].[HasAmountDeficiency], [p].[IdNumber], [p].[IdType], [p].[InvoiceId], [p].[IsActive], [p].[IsDeleted], [p].[IsReturned], [p].[IsTransfered], [p].[IssuedIn], [p].[LastModificationTime], [p].[LastModifierUserId], [p].[LocalPaymentOrderId], [p].[ParentId], [p].[PayFromOrganizationPhysicalAccountId], [p].[PayToCustomerContactId], [p].[PayerAgentId], [p].[PayerBranchId], [p].[PayerCustomerId], [p].[PaymentMethod], [p].[PaymentRequestId], [p].[ReasonId], [p].[ReferDate], [p].[ReferralType], [p].[Status], [p].[TradingUnitId], [p].[UserId], [t0].[Id], [t0].[Address], [t0].[BirthDate], [t0].[BrandName], [t0].[CorporateNumber], [t0].[CreationTime], [t0].[CreatorUserId], [t0].[DeleterUserId], [t0].[DeletionTime], [t0].[EconomicCode], [t0].[EnglishJob], [t0].[EnglishName], [t0].[FatherName], [t0].[GoogleRegistrationId], [t0].[ICNumber], [t0].[IsAgent], [t0].[IsContractor], [t0].[IsCorporate], [t0].[IsCustomer], [t2].[DeletionTime], [t2].[DepositToCustomerBankAccountId], [t2].[Description], [t2].[FormalDateTime], [t2].[Guid], [t2].[HasAmountDeficiency], [t2].[IdNumber], [t2].[IdType], [t2].[InvoiceId], [t2].[IsActive], [t2].[IsDeleted], [t2].[IsReturned], [t2].[IsTransfered], [t2].[IssuedIn], [t2].[LastModificationTime], [t2].[LastModifierUserId], [t2].[LocalPaymentOrderId], [t2].[ParentId], [t2].[PayFromOrganizationPhysicalAccountId], [t2].[PayToCustomerContactId], [t2].[PayerAgentId], [t2].[PayerBranchId], [t2].[PayerCustomerId], [t2].[PaymentMethod], [t2].[PaymentRequestId], [t2].[ReasonId], [t2].[ReferDate], [t2].[ReferralType], [t2].[Status], [t2].[TradingUnitId], [t2].[UserId], [t3].[Id], [t3].[AbbrivationChar], [t3].[CityId], [t3].[Code], [t3].[CreationTime], [t3].[CreatorUserId], [t3].[DeleterUserId], [t3].[DeletionTime], [t3].[EnName], [t3].[Guid], 
FROM [Sales].[PaymentOrders] AS [p]
LEFT JOIN (
    SELECT [p0].[Id], [p0].[AgentReceiptLocation], [p0].[Amount], [p0].[AttachmentId], [p0].[CostCenterId1], [p0].[CostCenterId2], [p0].[CreationTime], [p0].[CreatorUserId], [p0].[DeleterUserId], [p0].[DeletionTime], [p0].[DepositToCustomerBankAccountId], [p0].[Description], [p0].[FintracPrintCount], [p0].[FormalDateTime], [p0].[Guid], [p0].[InvoiceId], [p0].[IsActive], [p0].[IsDeleted], [p0].[IsFinalizedByJob], [p0].[IsReturned], [p0].[IssuerBranchId], [p0].[LastModificationTime], [p0].[LastModifierUserId], [p0].[LocalPaymentOrderId], [p0].[PayFromOrganizationPhysicalAccountId], [p0].[PayToCustomerContactId], [p0].[PayerAgentId], [p0].[PaymentRequestMethod], [p0].[PaymentRequestTypeId], [p0].[ProcessorBranchEditorUserId], [p0].[ProcessorBranchId], [p0].[ProcessorBranchModifiedDate], [p0].[PurposeOfTransaction], [p0].[ReasonId], [p0].[ReceiverBranchId], [p0].[ReferDate], [p0].[SourceOfFund], [p0].[Status], [p0].[SubmitMethod], [p0].[TradingUnitId], [p0].[TradingUnitType], [p0].[UserId]
    FROM [Sales].[PaymentRequests] AS [p0]
    WHERE [p0].[IsDeleted] = CAST(0 AS bit)
) AS [t] ON [p].[PaymentRequestId] = [t].[Id]
INNER JOIN (
    SELECT [u].[Id], [u].[Address], [u].[BirthDate], [u].[BrandName], [u].[CorporateNumber], [u].[CreationTime], [u].[CreatorUserId], [u].[DeleterUserId], [u].[DeletionTime], [u].[EconomicCode], [u].[EnglishJob], [u].[EnglishName], [u].[FatherName], [u].[GoogleRegistrationId], [u].[ICNumber], [u].[IsAgent], [u].[IsContractor], [u].[IsCorporate], [u].[IsCustomer], [u].[IsDeleted], [u].[IsEmployee], [u].[Job], [u].[LastModificationTime], [u].[LastModifierUserId], [u].[ManagingDirector], [u].[NationalId], [u].[NationalityId], [u].[OtherIdentityNumbers], [u].[PassportNumber], [u].[PersianName], [u].[ProfilePictureId], [u].[ProhibitedTransaction], [u].[RegistrarBranchId], [u].[RegistrationMethod], [u].[RegistrationNumber], [u].[ResidencyCityId], [u].[ResidencyId], [u].[SocialSecurityNumber], [u].[UNNumber], [u].[UserName]
    FROM [Users].[Users] AS [u]
    WHERE [u].[IsDeleted] = CAST(0 AS bit)
) AS [t0] ON [p].[CreatorUserId] = [t0].[Id]
INNER JOIN (
    SELECT [b].[Id], [b].[AbbrivationChar], [b].[CityId], [b].[Code], [b].[CreationTime], [b].[CreatorUserId], [b].[DeleterUserId], [b].[DeletionTime], [b].[EnName], [b].[Guid], [b].[IsCentralBranch], [b].[IsDeleted], [b].[Language], [b].[LastModificationTime], [b].[LastModifierUserId], [b].[Name], [b].[StandardTimeZoneInfo], [b].[UseGregorianCalendar]
    FROM [Organization].[Branches] AS [b]
    WHERE [b].[IsDeleted] = CAST(0 AS bit)
) AS [t1] ON [p].[BranchId] = [t1].[Id]
LEFT JOIN (
    SELECT [p2].[Id], [p2].[Amount], [p2].[AttachmentId], [p2].[BranchId], [p2].[CostCenterId1], [p2].[CostCenterId2], [p2].[CreationTime], [p2].[CreatorUserId], [p2].[DOB], [p2].[DeleterUserId], [p2].[DeletionTime], [p2].[DepositToCustomerBankAccountId], [p2].[Description], [p2].[FormalDateTime], [p2].[Guid], [p2].[HasAmountDeficiency], [p2].[IdNumber], [p2].[IdType], [p2].[InvoiceId], [p2].[IsActive], [p2].[IsDeleted], [p2].[IsReturned], [p2].[IsTransfered], [p2].[IssuedIn], [p2].[LastModificationTime], [p2].[LastModifierUserId], [p2].[LocalPaymentOrderId], [p2].[ParentId], [p2].[PayFromOrganizationPhysicalAccountId], [p2].[PayToCustomerContactId], [p2].[PayerAgentId], [p2].[PayerBranchId], [p2].[PayerCustomerId], [p2].[PaymentMethod], [p2].[PaymentRequestId], [p2].[ReasonId], [p2].[ReferDate], [p2].[ReferralType], [p2].[Status], [p2].[TradingUnitId], [p2].[UserId]
    FROM [Sales].[PaymentOrders] AS [p2]
    WHERE [p2].[IsDeleted] = CAST(0 AS bit)
) AS [t2] ON [p].[ParentId] = [t2].[Id]
LEFT JOIN (
    SELECT [b0].[Id], [b0].[AbbrivationChar], [b0].[CityId], [b0].[Code], [b0].[CreationTime], [b0].[CreatorUserId], [b0].[DeleterUserId], [b0].[DeletionTime], [b0].[EnName], [b0].[Guid], [b0].[IsCentralBranch], [b0].[IsDeleted], [b0].[Language], [b0].[LastModificationTime], [b0].[LastModifierUserId], [b0].[Name], [b0].[StandardTimeZoneInfo], [b0].[UseGregorianCalendar]
    FROM [Organization].[Branches] AS [b0]
    WHERE [b0].[IsDeleted] = CAST(0 AS bit)
) AS [t3] ON [p].[PayerBranchId] = [t3].[Id]
INNER JOIN (
    SELECT [t5].[Id], [t5].[CreationTime], [t5].[CreatorUserId], [t5].[DecimalPlaces], [t5].[DeleterUserId], [t5].[DeletionTime], [t5].[EnName], [t5].[InvoiceReceiptApprovalBranchId], [t5].[IsActive], [t5].[IsDeleted], [t5].[LastModificationTime], [t5].[LastModifierUserId], [t5].[Name], [t5].[OriginCountryId], [t5].[Priority], [t5].[Symbol], [t5].[Tolerance], [t5].[TradingUnitCategory], [t5].[TradingUnitType]
    FROM [Common].[TradingUnits] AS [t5]
    WHERE [t5].[IsDeleted] = CAST(0 AS bit)
) AS [t4] ON [p].[TradingUnitId] = [t4].[Id]
LEFT JOIN (
    SELECT [u0].[Id], [u0].[Address], [u0].[BirthDate], [u0].[BrandName], [u0].[CorporateNumber], [u0].[CreationTime], [u0].[CreatorUserId], [u0].[DeleterUserId], [u0].[DeletionTime], [u0].[EconomicCode], [u0].[EnglishJob], [u0].[EnglishName], [u0].[FatherName], [u0].[GoogleRegistrationId], [u0].[ICNumber], [u0].[IsAgent], [u0].[IsContractor], [u0].[IsCorporate], [u0].[IsCustomer], [u0].[IsDeleted], [u0].[IsEmployee], [u0].[Job], [u0].[LastModificationTime], [u0].[LastModifierUserId], [u0].[ManagingDirector], [u0].[NationalId], [u0].[NationalityId], [u0].[OtherIdentityNumbers], [u0].[PassportNumber], [u0].[PersianName], [u0].[ProfilePictureId], [u0].[ProhibitedTransaction], [u0].[RegistrarBranchId], [u0].[RegistrationMethod], [u0].[RegistrationNumber], [u0].[ResidencyCityId], [u0].[ResidencyId], [u0].[SocialSecurityNumber], [u0].[UNNumber], [u0].[UserName]
    FROM [Users].[Users] AS [u0]
    WHERE [u0].[IsDeleted] = CAST(0 AS bit)
) AS [t6] ON [p].[UserId] = [t6].[Id]
LEFT JOIN (
    SELECT [p3].[Id], [p3].[CreationTime], [p3].[CreatorUserId], [p3].[DeleterUserId], [p3].[DeletionTime], [p3].[EnglishName], [p3].[IsActive], [p3].[IsDeleted], [p3].[LastModificationTime], [p3].[LastModifierUserId], [p3].[PersianName], [p3].[Priority]
    FROM [Sales].[PaymentRequestTypes] AS [p3]
    WHERE [p3].[IsDeleted] = CAST(0 AS bit)
) AS [t7] ON [t].[PaymentRequestTypeId] = [t7].[Id]
LEFT JOIN (
    SELECT [i].[Id], [i].[Amount], [i].[BranchId], [i].[ConfirmedWithoutCheckout], [i].[CostCenterId1], [i].[CostCenterId2], [i].[CreationTime], [i].[CreatorUserId], [i].[DealingType], [i].[DeleterUserId], [i].[DeletionTime], [i].[Description], [i].[DestinationTradingUnitId], [i].[DirectCompletion], [i].[Discount], [i].[DisplayTradingUnitRate], [i].[FormalDateTime], [i].[Guid], [i].[InPerson], [i].[InputBranchId], [i].[InvoiceNumber], [i].[InvoiceType], [i].[IsDeleted], [i].[IsExchangeInvoice], [i].[IsReturned], [i].[LastModificationTime], [i].[LastModifierUserId], [i].[LocalPaymentOrderId], [i].[OutputBranchId], [i].[PayableTotal], [i].[RateReverseCalculation], [i].[ReasonId], [i].[ReceiptApprovalBranchId], [i].[ReceivableTotal], [i].[SourceTradingUnitId], [i].[Status], [i].[SubmitMethod], [i].[TradingUnitRate], [i].[TradingUnitType], [i].[UserId], [i].[WageInDestination], [i].[WageInSource], [i].[WageTradingUnitId], [i].[WageTradingUnitSymbol]
    FROM [Sales].[Invoices] AS [i]
    WHERE [i].[IsDeleted] = CAST(0 AS bit)
) AS [t8] ON [t].[InvoiceId] = [t8].[Id]
WHERE (((((([p].[IsDeleted] = CAST(0 AS bit)) AND ([p].[Status] = CAST(3 AS smallint))) AND ([p].[ReferralType] = CAST(3 AS smallint))) AND ((([p].[BranchId] IN (7, 12, 6, 13, 14, 5) OR [p].[PayerBranchId] IN (7, 12, 6, 13, 14, 5)) AND ([p].[IsActive] = CAST(1 AS bit))) AND ([p].[ReferralType] = @__input_ReferralType_1))) AND (CAST([p].[Status] AS smallint) = CAST(3 AS smallint))) AND ((([p].[PaymentRequestId] IS NOT NULL) AND EXISTS (
    SELECT 1
    FROM [Sales].[PaymentRequestTypes] AS [p1]
    WHERE (([p1].[IsDeleted] = CAST(0 AS bit)) AND EXISTS (
        SELECT 1
        FROM [Organization].[EmployeePaymentRequestTypes] AS [e]
        WHERE (([e].[IsDeleted] = CAST(0 AS bit)) AND ([e].[EmployeeId] = @__GetUserId_3)) AND ([e].[PaymentRequestTypeId] = [p1].[Id]))) AND ([p1].[Id] = [t].[PaymentRequestTypeId]))) OR ([p].[PaymentRequestId] IS NULL))) AND ([p].[PayerBranchId] = @__input_BranchId_4)
ORDER BY [p].[LastModificationTime] DESC, [p].[CreationTime] DESC

和 SQLAfter

DECLARE @__input_ReferralType_1 smallint = CAST(3 AS smallint);
DECLARE @__GetUserId_3 nvarchar(450) = N'a4bf84af-0758-4b08-8c1c-240ca0892afa';
DECLARE @__input_BranchId_4 int = 12;
DECLARE @__p_5 int = 0;
DECLARE @__p_6 int = 10;

SELECT [t0].[Id], [t0].[Amount], [t0].[AttachmentId], [t0].[BranchId], [t0].[CostCenterId1], [t0].[CostCenterId2], [t0].[CreationTime], [t0].[CreatorUserId], [t0].[DOB], [t0].[DeleterUserId], [t0].[DeletionTime], [t0].[DepositToCustomerBankAccountId], [t0].[Description], [t0].[FormalDateTime], [t0].[Guid], [t0].[HasAmountDeficiency], [t0].[IdNumber], [t0].[IdType], [t0].[InvoiceId], [t0].[IsActive], [t0].[IsDeleted], [t0].[IsReturned], [t0].[IsTransfered], [t0].[IssuedIn], [t0].[LastModificationTime], [t0].[LastModifierUserId], [t0].[LocalPaymentOrderId], [t0].[ParentId], [t0].[PayFromOrganizationPhysicalAccountId], [t0].[PayToCustomerContactId], [t0].[PayerAgentId], [t0].[PayerBranchId], [t0].[PayerCustomerId], [t0].[PaymentMethod], [t0].[PaymentRequestId], [t0].[ReasonId], [t0].[ReferDate], [t0].[ReferralType], [t0].[Status], [t0].[TradingUnitId], [t0].[UserId], [t1].[Id], [t1].[Address], [t1].[BirthDate], [t1].[BrandName], [t1].[CorporateNumber], [t1].[CreationTime], [t1].[CreatorUserId], [t1].[DeleterUserId], [t1].[DeletionTime], [t1].[EconomicCode], [t1].[EnglishJob], [t1].[EnglishName], [t1].[FatherName], [t1].[GoogleRegistrationId], [t1].[ICNumber], [t1].[IsAgent], [t1].[IsContractor], [t1].[IsCorporate], [t1].[IsCustomer], [t1].[IsDeleted], [t1].[IsEmployee], [t1].[Job], [t1].[LastModificationTime], [t1].[LastModifierUserId], [t1].[ManagingDirector], [t1].[NationalId], [t1].[NationalityId], [t1].[OtherIdentityNumbers], [t1].[PassportNumber], [t1].[PersianName], [t1].[ProfilePictureId], [t1].[ProhibitedTransaction], [t1].[RegistrarBranchId], [t1].[RegistrationMethod], [t1].[RegistrationNumber], [t1].[ResidencyCityId], [t1].[ResidencyId], [t1].[SocialSecurityNumber], [t1].[UNNumber], [t1].[UserName], [t2].[Id], [t2].[AbbrivationChar], [t2].[CityId], [t2].[Code], [t2].[CreationTime], [t2].[CreatorUserId], [t2].[DeleterUserId], [t2].[DeletionTime], [t2].[EnName], [t2].[Guid], [t2].[IsCentralBranch], [t2].[IsDeleted], [t2].[Language], [t2].[LastModificationTime], [t2].[LastModifierUserId], [t2].[Name], [t2].[StandardTimeZoneInfo], [t2].[UseGregorianCalendar], [t3].[Id], [t3].[Amount], [t3].[AttachmentId], [t3].[BranchId], [t3].[CostCenterId1], [t3].[CostCenterId2], [t3].[CreationTime], [t3].[CreatorUserId], [t3].[DOB], [t3].[DeleterUserId], [t3].[DeletionTime], [t3].[DepositToCustomerBankAccountId], [t3].[Description], [t3].[FormalDateTime], [t3].[Guid], [t3].[HasAmountDeficiency], [t3].[IdNumber], [t3].[IdType], [t3].[InvoiceId], [t3].[IsActive], [t3].[IsDeleted], [t3].[IsReturned], [t3].[IsTransfered], [t3].[IssuedIn], [t3].[LastModificationTime], [t3].[LastModifierUserId], [t3].[LocalPaymentOrderId], [t3].[ParentId], [t3].[PayFromOrganizationPhysicalAccountId], [t3].[PayToCustomerContactId], [t3].[PayerAgentId], [t3].[PayerBranchId], [t3].[PayerCustomerId], [t3].[PaymentMethod], [t3].[PaymentRequestId], [t3].[ReasonId], [t3].[ReferDate], [t3].[ReferralType], [t3].[Status], [t3].[TradingUnitId], [t3].[UserId], [t4].[Id], [t4].[AbbrivationChar], [t4].[CityId], [t4].[Code], [t4].[CreationTime], [t4].[CreatorUserId], [t4].[DeleterUserId], [t4].[DeletionTime], [t4].[EnName], [t4].[Guid], [t4].[IsCentralBranch], [t4].[IsDeleted], [t4].[Language], [t4].[LastModificationTime], [t4].[LastModifierUserId], [t4].[Name], [t4].[StandardTimeZoneInfo], [t4].[UseGregorianCalendar], [t5].[Id], [t5].[CreationTime], [t5].[CreatorUserId], [t5].[DecimalPlaces], [t5].[DeleterUserId], [t5].[DeletionTime], [t5].[EnName], [t5].[InvoiceReceiptApprovalBranchId], [t5].[IsActive], [t5].[IsDeleted], [t5].[LastModificationTime], [t5].[LastModifierUserId], [t5].[Name], [t5].[OriginCountryId], [t5].[Priority], [t5].[Symbol], [t5].[Tolerance], [t5].[TradingUnitCategory], [t5].[TradingUnitType], [t7].[Id], [t7].[Address], [t7].[BirthDate], [t7].[BrandName], [t7].[CorporateNumber], [t7].[CreationTime], [t7].[CreatorUserId], [t7].[DeleterUserId], [t7].[DeletionTime], [t7].[EconomicCode], [t7].[EnglishJob], [t7].[EnglishName], [t7].[FatherName], [t7].[GoogleRegistrationId], [t7].[ICNumber], [t7].[IsAgent], [t7].[IsContractor], [t7].[IsCorporate], [t7].[IsCustomer], [t7].[IsDeleted], [t7].[IsEmployee], [t7].[Job], [t7].[LastModificationTime], [t7].[LastModifierUserId], [t7].[ManagingDirector], [t7].[NationalId], [t7].[NationalityId], [t7].[OtherIdentityNumbers], [t7].[PassportNumber], [t7].[PersianName], [t7].[ProfilePictureId], [t7].[ProhibitedTransaction], [t7].[RegistrarBranchId], [t7].[RegistrationMethod], [t7].[RegistrationNumber], [t7].[ResidencyCityId], [t7].[ResidencyId], [t7].[SocialSecurityNumber], [t7].[UNNumber], [t7].[UserName], [t0].[Id0], [t0].[AgentReceiptLocation], [t0].[Amount0], [t0].[AttachmentId0], [t0].[CostCenterId10], [t0].[CostCenterId20], [t0].[CreationTime0], [t0].[CreatorUserId0], [t0].[DeleterUserId0], [t0].[DeletionTime0], [t0].[DepositToCustomerBankAccountId0], [t0].[Description0], [t0].[FintracPrintCount], [t0].[FormalDateTime0], [t0].[Guid0], [t0].[InvoiceId0], [t0].[IsActive0], [t0].[IsDeleted0], [t0].[IsFinalizedByJob], [t0].[IsReturned0], [t0].[IssuerBranchId], [t0].[LastModificationTime0], [t0].[LastModifierUserId0], [t0].[LocalPaymentOrderId0], [t0].[PayFromOrganizationPhysicalAccountId0], [t0].[PayToCustomerContactId0], [t0].[PayerAgentId0], [t0].[PaymentRequestMethod], [t0].[PaymentRequestTypeId], [t0].[ProcessorBranchEditorUserId], [t0].[ProcessorBranchId], [t0].[ProcessorBranchModifiedDate], [t0].[PurposeOfTransaction], [t0].[ReasonId0], [t0].[ReceiverBranchId], [t0].[ReferDate0], [t0].[SourceOfFund], [t0].[Status0], [t0].[SubmitMethod], [t0].[TradingUnitId0], [t0].[TradingUnitType], [t0].[UserId0], [t8].[Id], [t8].[CreationTime], [t8].[CreatorUserId], [t8].[DeleterUserId], [t8].[DeletionTime], [t8].[EnglishName], [t8].[IsActive], [t8].[IsDeleted], [t8].[LastModificationTime], [t8].[LastModifierUserId], [t8].[PersianName], [t8].[Priority], [t9].[Id], [t9].[Amount], [t9].[BranchId], [t9].[ConfirmedWithoutCheckout], [t9].[CostCenterId1], [t9].[CostCenterId2], [t9].[CreationTime], [t9].[CreatorUserId], [t9].[DealingType], [t9].[DeleterUserId], [t9].[DeletionTime], [t9].[Description], [t9].[DestinationTradingUnitId], [t9].[DirectCompletion], [t9].[Discount], [t9].[DisplayTradingUnitRate], [t9].[FormalDateTime], [t9].[Guid], [t9].[InPerson], [t9].[InputBranchId], [t9].[InvoiceNumber], [t9].[InvoiceType], [t9].[IsDeleted], [t9].[IsExchangeInvoice], [t9].[IsReturned], [t9].[LastModificationTime], [t9].[LastModifierUserId], [t9].[LocalPaymentOrderId], [t9].[OutputBranchId], [t9].[PayableTotal], [t9].[RateReverseCalculation], [t9].[ReasonId], [t9].[ReceiptApprovalBranchId], [t9].[ReceivableTotal], [t9].[SourceTradingUnitId], [t9].[Status], [t9].[SubmitMethod], [t9].[TradingUnitRate], [t9].[TradingUnitType], [t9].[UserId], [t9].[WageInDestination], [t9].[WageInSource], [t9].[WageTradingUnitId], [t9].[WageTradingUnitSymbol]
FROM (
    SELECT [p].[Id], [p].[Amount], [p].[AttachmentId], [p].[BranchId], [p].[CostCenterId1], [p].[CostCenterId2], [p].[CreationTime], [p].[CreatorUserId], [p].[DOB], [p].[DeleterUserId], [p].[DeletionTime], [p].[DepositToCustomerBankAccountId], [p].[Description], [p].[FormalDateTime], [p].[Guid], [p].[HasAmountDeficiency], [p].[IdNumber], [p].[IdType], [p].[InvoiceId], [p].[IsActive], [p].[IsDeleted], [p].[IsReturned], [p].[IsTransfered], [p].[IssuedIn], [p].[LastModificationTime], [p].[LastModifierUserId], [p].[LocalPaymentOrderId], [p].[ParentId], [p].[PayFromOrganizationPhysicalAccountId], [p].[PayToCustomerContactId], [p].[PayerAgentId], [p].[PayerBranchId], [p].[PayerCustomerId], [p].[PaymentMethod], [p].[PaymentRequestId], [p].[ReasonId], [p].[ReferDate], [p].[ReferralType], [p].[Status], [p].[TradingUnitId], [p].[UserId], [t].[Id] AS [Id0], [t].[AgentReceiptLocation], [t].[Amount] AS [Amount0], [t].[AttachmentId] AS [AttachmentId0], [t].[CostCenterId1] AS [CostCenterId10], [t].[CostCenterId2] AS [CostCenterId20], [t].[CreationTime] AS [CreationTime0], [t].[CreatorUserId] AS [CreatorUserId0], [t].[DeleterUserId] AS [DeleterUserId0], [t].[DeletionTime] AS [DeletionTime0], [t].[DepositToCustomerBankAccountId] AS [DepositToCustomerBankAccountId0], [t].[Description] AS [Description0], [t].[FintracPrintCount], [t].[FormalDateTime] AS [FormalDateTime0], [t].[Guid] AS [Guid0], [t].[InvoiceId] AS [InvoiceId0], [t].[IsActive] AS [IsActive0], [t].[IsDeleted] AS [IsDeleted0], [t].[IsFinalizedByJob], [t].[IsReturned] AS [IsReturned0], [t].[IssuerBranchId], [t].[LastModificationTime] AS [LastModificationTime0], [t].[LastModifierUserId] AS [LastModifierUserId0], [t].[LocalPaymentOrderId] AS [LocalPaymentOrderId0], [t].[PayFromOrganizationPhysicalAccountId] AS [PayFromOrganizationPhysicalAccountId0], [t].[PayToCustomerContactId] AS [PayToCustomerContactId0], [t].[PayerAgentId] AS [PayerAgentId0], [t].[PaymentRequestMethod], [t].[PaymentRequestTypeId], [t].[ProcessorBranchEditorUserId], [t].[ProcessorBranchId], [t].[ProcessorBranchModifiedDate], [t].[PurposeOfTransaction], [t].[ReasonId] AS [ReasonId0], [t].[ReceiverBranchId], [t].[ReferDate] AS [ReferDate0], [t].[SourceOfFund], [t].[Status] AS [Status0], [t].[SubmitMethod], [t].[TradingUnitId] AS [TradingUnitId0], [t].[TradingUnitType], [t].[UserId] AS [UserId0]
    FROM [Sales].[PaymentOrders] AS [p]
    LEFT JOIN (
        SELECT [p0].[Id], [p0].[AgentReceiptLocation], [p0].[Amount], [p0].[AttachmentId], [p0].[CostCenterId1], [p0].[CostCenterId2], [p0].[CreationTime], [p0].[CreatorUserId], [p0].[DeleterUserId], [p0].[DeletionTime], [p0].[DepositToCustomerBankAccountId], [p0].[Description], [p0].[FintracPrintCount], [p0].[FormalDateTime], [p0].[Guid], [p0].[InvoiceId], [p0].[IsActive], [p0].[IsDeleted], [p0].[IsFinalizedByJob], [p0].[IsReturned], [p0].[IssuerBranchId], [p0].[LastModificationTime], [p0].[LastModifierUserId], [p0].[LocalPaymentOrderId], [p0].[PayFromOrganizationPhysicalAccountId], [p0].[PayToCustomerContactId], [p0].[PayerAgentId], [p0].[PaymentRequestMethod], [p0].[PaymentRequestTypeId], [p0].[ProcessorBranchEditorUserId], [p0].[ProcessorBranchId], [p0].[ProcessorBranchModifiedDate], [p0].[PurposeOfTransaction], [p0].[ReasonId], [p0].[ReceiverBranchId], [p0].[ReferDate], [p0].[SourceOfFund], [p0].[Status], [p0].[SubmitMethod], [p0].[TradingUnitId], [p0].[TradingUnitType], [p0].[UserId]
        FROM [Sales].[PaymentRequests] AS [p0]
        WHERE [p0].[IsDeleted] = CAST(0 AS bit)
    ) AS [t] ON [p].[PaymentRequestId] = [t].[Id]
    WHERE (((((([p].[IsDeleted] = CAST(0 AS bit)) AND ([p].[Status] = CAST(3 AS smallint))) AND ([p].[ReferralType] = CAST(3 AS smallint))) AND ((([p].[BranchId] IN (7, 12, 6, 13, 14, 5) OR [p].[PayerBranchId] IN (7, 12, 6, 13, 14, 5)) AND ([p].[IsActive] = CAST(1 AS bit))) AND ([p].[ReferralType] = @__input_ReferralType_1))) AND (CAST([p].[Status] AS smallint) = CAST(3 AS smallint))) AND ((([p].[PaymentRequestId] IS NOT NULL) AND EXISTS (
        SELECT 1
        FROM [Sales].[PaymentRequestTypes] AS [p1]
        WHERE (([p1].[IsDeleted] = CAST(0 AS bit)) AND EXISTS (
            SELECT 1
            FROM [Organization].[EmployeePaymentRequestTypes] AS [e]
            WHERE (([e].[IsDeleted] = CAST(0 AS bit)) AND ([e].[EmployeeId] = @__GetUserId_3)) AND ([e].[PaymentRequestTypeId] = [p1].[Id]))) AND ([p1].[Id] = [t].[PaymentRequestTypeId]))) OR ([p].[PaymentRequestId] IS NULL))) AND ([p].[PayerBranchId] = @__input_BranchId_4)
    ORDER BY [p].[LastModificationTime] DESC, [p].[CreationTime] DESC
    OFFSET @__p_5 ROWS FETCH NEXT @__p_6 ROWS ONLY
) AS [t0]
INNER JOIN (
    SELECT [u].[Id], [u].[Address], [u].[BirthDate], [u].[BrandName], [u].[CorporateNumber], [u].[CreationTime], [u].[CreatorUserId], [u].[DeleterUserId], [u].[DeletionTime], [u].[EconomicCode], [u].[EnglishJob], [u].[EnglishName], [u].[FatherName], [u].[GoogleRegistrationId], [u].[ICNumber], [u].[IsAgent], [u].[IsContractor], [u].[IsCorporate], [u].[IsCustomer], [u].[IsDeleted], [u].[IsEmployee], [u].[Job], [u].[LastModificationTime], [u].[LastModifierUserId], [u].[ManagingDirector], [u].[NationalId], [u].[NationalityId], [u].[OtherIdentityNumbers], [u].[PassportNumber], [u].[PersianName], [u].[ProfilePictureId], [u].[ProhibitedTransaction], [u].[RegistrarBranchId], [u].[RegistrationMethod], [u].[RegistrationNumber], [u].[ResidencyCityId], [u].[ResidencyId], [u].[SocialSecurityNumber], [u].[UNNumber], [u].[UserName]
    FROM [Users].[Users] AS [u]
    WHERE [u].[IsDeleted] = CAST(0 AS bit)
) AS [t1] ON [t0].[CreatorUserId] = [t1].[Id]
INNER JOIN (
    SELECT [b].[Id], [b].[AbbrivationChar], [b].[CityId], [b].[Code], [b].[CreationTime], [b].[CreatorUserId], [b].[DeleterUserId], [b].[DeletionTime], [b].[EnName], [b].[Guid], [b].[IsCentralBranch], [b].[IsDeleted], [b].[Language], [b].[LastModificationTime], [b].[LastModifierUserId], [b].[Name], [b].[StandardTimeZoneInfo], [b].[UseGregorianCalendar]
    FROM [Organization].[Branches] AS [b]
    WHERE [b].[IsDeleted] = CAST(0 AS bit)
) AS [t2] ON [t0].[BranchId] = [t2].[Id]
LEFT JOIN (
    SELECT [p2].[Id], [p2].[Amount], [p2].[AttachmentId], [p2].[BranchId], [p2].[CostCenterId1], [p2].[CostCenterId2], [p2].[CreationTime], [p2].[CreatorUserId], [p2].[DOB], [p2].[DeleterUserId], [p2].[DeletionTime], [p2].[DepositToCustomerBankAccountId], [p2].[Description], [p2].[FormalDateTime], [p2].[Guid], [p2].[HasAmountDeficiency], [p2].[IdNumber], [p2].[IdType], [p2].[InvoiceId], [p2].[IsActive], [p2].[IsDeleted], [p2].[IsReturned], [p2].[IsTransfered], [p2].[IssuedIn], [p2].[LastModificationTime], [p2].[LastModifierUserId], [p2].[LocalPaymentOrderId], [p2].[ParentId], [p2].[PayFromOrganizationPhysicalAccountId], [p2].[PayToCustomerContactId], [p2].[PayerAgentId], [p2].[PayerBranchId], [p2].[PayerCustomerId], [p2].[PaymentMethod], [p2].[PaymentRequestId], [p2].[ReasonId], [p2].[ReferDate], [p2].[ReferralType], [p2].[Status], [p2].[TradingUnitId], [p2].[UserId]
    FROM [Sales].[PaymentOrders] AS [p2]
    WHERE [p2].[IsDeleted] = CAST(0 AS bit)
) AS [t3] ON [t0].[ParentId] = [t3].[Id]
LEFT JOIN (
    SELECT [b0].[Id], [b0].[AbbrivationChar], [b0].[CityId], [b0].[Code], [b0].[CreationTime], [b0].[CreatorUserId], [b0].[DeleterUserId], [b0].[DeletionTime], [b0].[EnName], [b0].[Guid], [b0].[IsCentralBranch], [b0].[IsDeleted], [b0].[Language], [b0].[LastModificationTime], [b0].[LastModifierUserId], [b0].[Name], [b0].[StandardTimeZoneInfo], [b0].[UseGregorianCalendar]
    FROM [Organization].[Branches] AS [b0]
    WHERE [b0].[IsDeleted] = CAST(0 AS bit)
) AS [t4] ON [t0].[PayerBranchId] = [t4].[Id]
INNER JOIN (
    SELECT [t6].[Id], [t6].[CreationTime], [t6].[CreatorUserId], [t6].[DecimalPlaces], [t6].[DeleterUserId], [t6].[DeletionTime], [t6].[EnName], [t6].[InvoiceReceiptApprovalBranchId], [t6].[IsActive], [t6].[IsDeleted], [t6].[LastModificationTime], [t6].[LastModifierUserId], [t6].[Name], [t6].[OriginCountryId], [t6].[Priority], [t6].[Symbol], [t6].[Tolerance], [t6].[TradingUnitCategory], [t6].[TradingUnitType]
    FROM [Common].[TradingUnits] AS [t6]
    WHERE [t6].[IsDeleted] = CAST(0 AS bit)
) AS [t5] ON [t0].[TradingUnitId] = [t5].[Id]
LEFT JOIN (
    SELECT [u0].[Id], [u0].[Address], [u0].[BirthDate], [u0].[BrandName], [u0].[CorporateNumber], [u0].[CreationTime], [u0].[CreatorUserId], [u0].[DeleterUserId], [u0].[DeletionTime], [u0].[EconomicCode], [u0].[EnglishJob], [u0].[EnglishName], [u0].[FatherName], [u0].[GoogleRegistrationId], [u0].[ICNumber], [u0].[IsAgent], [u0].[IsContractor], [u0].[IsCorporate], [u0].[IsCustomer], [u0].[IsDeleted], [u0].[IsEmployee], [u0].[Job], [u0].[LastModificationTime], [u0].[LastModifierUserId], [u0].[ManagingDirector], [u0].[NationalId], [u0].[NationalityId], [u0].[OtherIdentityNumbers], [u0].[PassportNumber], [u0].[PersianName], [u0].[ProfilePictureId], [u0].[ProhibitedTransaction], [u0].[RegistrarBranchId], [u0].[RegistrationMethod], [u0].[RegistrationNumber], [u0].[ResidencyCityId], [u0].[ResidencyId], [u0].[SocialSecurityNumber], [u0].[UNNumber], [u0].[UserName]
    FROM [Users].[Users] AS [u0]
    WHERE [u0].[IsDeleted] = CAST(0 AS bit)
) AS [t7] ON [t0].[UserId] = [t7].[Id]
LEFT JOIN (
    SELECT [p3].[Id], [p3].[CreationTime], [p3].[CreatorUserId], [p3].[DeleterUserId], [p3].[DeletionTime], [p3].[EnglishName], [p3].[IsActive], [p3].[IsDeleted], [p3].[LastModificationTime], [p3].[LastModifierUserId], [p3].[PersianName], [p3].[Priority]
    FROM [Sales].[PaymentRequestTypes] AS [p3]
    WHERE [p3].[IsDeleted] = CAST(0 AS bit)
) AS [t8] ON [t0].[PaymentRequestTypeId] = [t8].[Id]
LEFT JOIN (
    SELECT [i].[Id], [i].[Amount], [i].[BranchId], [i].[ConfirmedWithoutCheckout], [i].[CostCenterId1], [i].[CostCenterId2], [i].[CreationTime], [i].[CreatorUserId], [i].[DealingType], [i].[DeleterUserId], [i].[DeletionTime], [i].[Description], [i].[DestinationTradingUnitId], [i].[DirectCompletion], [i].[Discount], [i].[DisplayTradingUnitRate], [i].[FormalDateTime], [i].[Guid], [i].[InPerson], [i].[InputBranchId], [i].[InvoiceNumber], [i].[InvoiceType], [i].[IsDeleted], [i].[IsExchangeInvoice], [i].[IsReturned], [i].[LastModificationTime], [i].[LastModifierUserId], [i].[LocalPaymentOrderId], [i].[OutputBranchId], [i].[PayableTotal], [i].[RateReverseCalculation], [i].[ReasonId], [i].[ReceiptApprovalBranchId], [i].[ReceivableTotal], [i].[SourceTradingUnitId], [i].[Status], [i].[SubmitMethod], [i].[TradingUnitRate], [i].[TradingUnitType], [i].[UserId], [i].[WageInDestination], [i].[WageInSource], [i].[WageTradingUnitId], [i].[WageTradingUnitSymbol]
    FROM [Sales].[Invoices] AS [i]
    WHERE [i].[IsDeleted] = CAST(0 AS bit)
) AS [t9] ON [t0].[InvoiceId0] = [t9].[Id]
ORDER BY [t0].[LastModificationTime] DESC, [t0].[CreationTime] DESC

嘗試在查詢結束時執行 ToListAsync() 示例: query=await _context.Exemple.Skip(pageNumber * pageSize).Take(pageSize).toListAsync()

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM