SELECT [UnionAll4].[Id] AS [C1], [UnionAll4].[Id1] AS [C2], [UnionAll4].[Id2] AS [C3], [UnionAll4].[Id3] AS [C4], [UnionAll4].[Score] AS [C5], [UnionAll4].[RegistrationRequestCode] AS [C6], [UnionAll4].[SignedDate] AS [C7], [UnionAll4].[RegistrationRequestState] AS [C8], [UnionAll4].[EvaluationDate] AS [C9], [UnionAll4].[Score1] AS [C10], [UnionAll4].[Reason] AS [C11], [UnionAll4].[Remark] AS [C12], [UnionAll4].[C2] AS [C13], [UnionAll4].[AuthorizedRepresentativeCompanyName] AS [C14], [UnionAll4].[AuthorizedRepresentativeVatNumber] AS [C15], [UnionAll4].[DeclarationPeriod] AS [C16], [UnionAll4].[ProfileType] AS [C17], [UnionAll4].[InternetSales] AS [C18], [UnionAll4].[OtherThanInternetSales] AS [C19], [UnionAll4].[C3] AS [C20], [UnionAll4].[BusinessRelationCode] AS [C21], [UnionAll4].[BicAccountNumber] AS [C22], [UnionAll4].[BusinessRelationName] AS [C23], [UnionAll4].[EmailAddress] AS [C24], [UnionAll4].[Fax] AS [C25], [UnionAll4].[FoundingDate] AS [C26], [UnionAll4].[IbanAccountNumber] AS [C27], [UnionAll4].[Telephone] AS [C28], [UnionAll4].[VatNumber] AS [C29], [UnionAll4].[IsVatObligated] AS [C30], [UnionAll4].[LanguageId] AS [C31], [UnionAll4].[FormOfGovernmentId] AS [C32], [UnionAll4].[RegistrationRequestBusinessRelationId] AS [C33], [UnionAll4].[RegistrationRequestGeneralId] AS [C34], [UnionAll4].[Score2] AS [C35], [UnionAll4].[AuthorizedRepresentativeCompanyName1] AS [C36], [UnionAll4].[AuthorizedRepresentativeVatNumber1] AS [C37], [UnionAll4].[DeclarationPeriod1] AS [C38], [UnionAll4].[ProfileType1] AS [C39], [UnionAll4].[InternetSales1] AS [C40], [UnionAll4].[OtherThanInternetSales1] AS [C41], [UnionAll4].[Score3] AS [C42], [UnionAll4].[BusinessRelationCode1] AS [C43], [UnionAll4].[BicAccountNumber1] AS [C44], [UnionAll4].[BusinessRelationName1] AS [C45], [UnionAll4].[EmailAddress1] AS [C46], [UnionAll4].[Fax1] AS [C47], [UnionAll4].[FoundingDate1] AS [C48], [UnionAll4].[IbanAccountNumber1] AS [C49], [UnionAll4].[Telephone1] AS [C50], [UnionAll4].[VatNumber1] AS [C51], [UnionAll4].[IsVatObligated1] AS [C52], [UnionAll4].[LanguageId1] AS [C53], [UnionAll4].[FormOfGovernmentId1] AS [C54], [UnionAll4].[RegistrationRequestBusinessRelationId1] AS [C55], [UnionAll4].[RegistrationRequestGeneralOriginalId] AS [C56], [UnionAll4].[CreatedDate] AS [C57], [UnionAll4].[CreatedBy] AS [C58], [UnionAll4].[LastModifiedDate] AS [C59], [UnionAll4].[LastModifiedBy] AS [C60], [UnionAll4].[Id4] AS [C61], [UnionAll4].[C4] AS [C62], [UnionAll4].[C1] AS [C63], [UnionAll4].[C5] AS [C64], [UnionAll4].[IsSigned] AS [C65], [UnionAll4].[C6] AS [C66], [UnionAll4].[Name] AS [C67], [UnionAll4].[DocumentPath] AS [C68], [UnionAll4].[CreatedDate1] AS [C69], [UnionAll4].[CreatedBy1] AS [C70], [UnionAll4].[LastModifiedDate1] AS [C71], [UnionAll4].[LastModifiedBy1] AS [C72], [UnionAll4].[AttachmentId] AS [C73], [UnionAll4].[Id5] AS [C74], [UnionAll4].[C7] AS [C75], [UnionAll4].[C8] AS [C76], [UnionAll4].[C9] AS [C77], [UnionAll4].[C10] AS [C78], [UnionAll4].[C11] AS [C79], [UnionAll4].[C12] AS [C80], [UnionAll4].[C13] AS [C81], [UnionAll4].[C14] AS [C82], [UnionAll4].[C15] AS [C83], [UnionAll4].[C16] AS [C84], [UnionAll4].[C17] AS [C85], [UnionAll4].[C18] AS [C86], [UnionAll4].[C19] AS [C87], [UnionAll4].[C20] AS [C88], [UnionAll4].[C21] AS [C89], [UnionAll4].[C22] AS [C90], [UnionAll4].[C23] AS [C91], [UnionAll4].[C24] AS [C92], [UnionAll4].[C25] AS [C93], [UnionAll4].[C26] AS [C94], [UnionAll4].[C27] AS [C95], [UnionAll4].[C28] AS [C96], [UnionAll4].[C29] AS [C97], [UnionAll4].[C30] AS [C98], [UnionAll4].[C31] AS [C99], [UnionAll4].[C32] AS [C100], [UnionAll4].[C33] AS [C101], [UnionAll4].[C34] AS [C102], [UnionAll4].[C35] AS [C103], [UnionAll4].[C36] AS [C104], [UnionAll4].[C37] AS [C105], [UnionAll4].[C38] AS [C106], [UnionAll4].[C39] AS [C107], [UnionAll4].[C40] AS [C108], [UnionAll4].[C41] AS [C109], [UnionAll4].[C42] AS [C110], [UnionAll4].[C43] AS [C111], [UnionAll4].[C44] AS [C112], [UnionAll4].[C45] AS [C113], [UnionAll4].[C46] AS [C114], [UnionAll4].[C47] AS [C115], [UnionAll4].[C48] AS [C116], [UnionAll4].[C49] AS [C117], [UnionAll4].[C50] AS [C118], [UnionAll4].[C51] AS [C119], [UnionAll4].[C52] AS [C120], [UnionAll4].[C53] AS [C121], [UnionAll4].[C54] AS [C122], [UnionAll4].[C55] AS [C123], [UnionAll4].[C56] AS [C124], [UnionAll4].[C57] AS [C125], [UnionAll4].[C58] AS [C126] FROM (SELECT CASE WHEN ([Join5].[Id1] IS NULL) THEN CAST(NULL AS int) ELSE 1 END AS [C1], [Limit1].[Id1] AS [Id], [Limit1].[Id2] AS [Id1], [Limit1].[Id3] AS [Id2], [Limit1].[Id4] AS [Id3], [Limit1].[Score] AS [Score], [Limit1].[RegistrationRequestCode] AS [RegistrationRequestCode], [Limit1].[SignedDate] AS [SignedDate], [Limit1].[RegistrationRequestState] AS [RegistrationRequestState], [Limit1].[EvaluationDate] AS [EvaluationDate], [Limit1].[Score] AS [Score1], [Limit1].[Reason] AS [Reason], [Limit1].[Remark] AS [Remark], [Limit1].[C1] AS [C2], [Limit1].[AuthorizedRepresentativeCompanyName] AS [AuthorizedRepresentativeCompanyName], [Limit1].[AuthorizedRepresentativeVatNumber] AS [AuthorizedRepresentativeVatNumber], [Limit1].[DeclarationPeriod] AS [DeclarationPeriod], [Limit1].[ProfileType] AS [ProfileType], [Limit1].[InternetSales] AS [InternetSales], [Limit1].[OtherThanInternetSales] AS [OtherThanInternetSales], [Limit1].[C2] AS [C3], [Limit1].[BusinessRelationCode] AS [BusinessRelationCode], [Limit1].[BicAccountNumber] AS [BicAccountNumber], [Limit1].[BusinessRelationName] AS [BusinessRelationName], [Limit1].[EmailAddress] AS [EmailAddress], [Limit1].[Fax] AS [Fax], [Limit1].[FoundingDate] AS [FoundingDate], [Limit1].[IbanAccountNumber] AS [IbanAccountNumber], [Limit1].[Telephone] AS [Telephone], [Limit1].[VatNumber] AS [VatNumber], [Limit1].[IsVatObligated] AS [IsVatObligated], [Limit1].[LanguageId] AS [LanguageId], [Limit1].[FormOfGovernmentId] AS [FormOfGovernmentId], [Limit1].[RegistrationRequestBusinessRelationId] AS [RegistrationRequestBusinessRelationId], [Limit1].[RegistrationRequestGeneralId] AS [RegistrationRequestGeneralId], [Limit1].[Score] AS [Score2], [Limit1].[AuthorizedRepresentativeCompanyName1] AS [AuthorizedRepresentativeCompanyName1], [Limit1].[AuthorizedRepresentativeVatNumber1] AS [AuthorizedRepresentativeVatNumber1], [Limit1].[DeclarationPeriod1] AS [DeclarationPeriod1], [Limit1].[ProfileType1] AS [ProfileType1], [Limit1].[InternetSales1] AS [InternetSales1], [Limit1].[OtherThanInternetSales1] AS [OtherThanInternetSales1], [Limit1].[Score] AS [Score3], [Limit1].[BusinessRelationCode1] AS [BusinessRelationCode1], [Limit1].[BicAccountNumber1] AS [BicAccountNumber1], [Limit1].[BusinessRelationName1] AS [BusinessRelationName1], [Limit1].[EmailAddress1] AS [EmailAddress1], [Limit1].[Fax1] AS [Fax1], [Limit1].[FoundingDate1] AS [FoundingDate1], [Limit1].[IbanAccountNumber1] AS [IbanAccountNumber1], [Limit1].[Telephone1] AS [Telephone1], [Limit1].[VatNumber1] AS [VatNumber1], [Limit1].[IsVatObligated1] AS [IsVatObligated1], [Limit1].[LanguageId1] AS [LanguageId1], [Limit1].[FormOfGovernmentId1] AS [FormOfGovernmentId1], [Limit1].[RegistrationRequestBusinessRelationId1] AS [RegistrationRequestBusinessRelationId1], [Limit1].[RegistrationRequestGeneralOriginalId] AS [RegistrationRequestGeneralOriginalId], [Limit1].[CreatedDate] AS [CreatedDate], [Limit1].[CreatedBy] AS [CreatedBy], [Limit1].[LastModifiedDate] AS [LastModifiedDate], [Limit1].[LastModifiedBy] AS [LastModifiedBy], [Limit1].[Id] AS [Id4], [Limit1].[C3] AS [C4], CASE WHEN ([Join5].[Id1] IS NULL) THEN CAST(NULL AS int) ELSE 1 END AS [C5], [Join5].[IsSigned] AS [IsSigned], CASE WHEN ([Join5].[Id1] IS NULL) THEN CAST(NULL AS int) WHEN ([Join5].[Id2] IS NOT NULL) THEN 1 END AS [C6], [Join5].[Name] AS [Name], [Join5].[DocumentPath] AS [DocumentPath], [Join5].[CreatedDate1] AS [CreatedDate1], [Join5].[CreatedBy1] AS [CreatedBy1], [Join5].[LastModifiedDate1] AS [LastModifiedDate1], [Join5].[LastModifiedBy1] AS [LastModifiedBy1], [Join5].[AttachmentId] AS [AttachmentId], [Join5].[Id1] AS [Id5], CAST(NULL AS int) AS [C7], CAST(NULL AS int) AS [C8], CAST(NULL AS int) AS [C9], CAST(NULL AS varchar(1)) AS [C10], CAST(NULL AS varchar(1)) AS [C11], CAST(NULL AS varchar(1)) AS [C12], CAST(NULL AS varchar(1)) AS [C13], CAST(NULL AS varchar(1)) AS [C14], CAST(NULL AS varchar(1)) AS [C15], CAST(NULL AS int) AS [C16], CAST(NULL AS int) AS [C17], CAST(NULL AS uniqueidentifier) AS [C18], CAST(NULL AS uniqueidentifier) AS [C19], CAST(NULL AS int) AS [C20], CAST(NULL AS int) AS [C21], CAST(NULL AS int) AS [C22], CAST(NULL AS varchar(1)) AS [C23], CAST(NULL AS varchar(1)) AS [C24], CAST(NULL AS varchar(1)) AS [C25], CAST(NULL AS varchar(1)) AS [C26], CAST(NULL AS varchar(1)) AS [C27], CAST(NULL AS varchar(1)) AS [C28], CAST(NULL AS int) AS [C29], CAST(NULL AS int) AS [C30], CAST(NULL AS uniqueidentifier) AS [C31], CAST(NULL AS uniqueidentifier) AS [C32], CAST(NULL AS int) AS [C33], CAST(NULL AS int) AS [C34], CAST(NULL AS int) AS [C35], CAST(NULL AS varchar(1)) AS [C36], CAST(NULL AS varchar(1)) AS [C37], CAST(NULL AS varchar(1)) AS [C38], CAST(NULL AS varchar(1)) AS [C39], CAST(NULL AS varchar(1)) AS [C40], CAST(NULL AS varchar(1)) AS [C41], CAST(NULL AS int) AS [C42], CAST(NULL AS int) AS [C43], CAST(NULL AS uniqueidentifier) AS [C44], CAST(NULL AS uniqueidentifier) AS [C45], CAST(NULL AS int) AS [C46], CAST(NULL AS int) AS [C47], CAST(NULL AS int) AS [C48], CAST(NULL AS varchar(1)) AS [C49], CAST(NULL AS varchar(1)) AS [C50], CAST(NULL AS varchar(1)) AS [C51], CAST(NULL AS varchar(1)) AS [C52], CAST(NULL AS varchar(1)) AS [C53], CAST(NULL AS varchar(1)) AS [C54], CAST(NULL AS int) AS [C55], CAST(NULL AS int) AS [C56], CAST(NULL AS uniqueidentifier) AS [C57], CAST(NULL AS uniqueidentifier) AS [C58] FROM (SELECT TOP (1) [Project1].[Id] AS [Id], [Project1].[RegistrationRequestGeneralOriginalId] AS [RegistrationRequestGeneralOriginalId], [Project1].[RegistrationRequestGeneralId] AS [RegistrationRequestGeneralId], [Project1].[SignedDate] AS [SignedDate], [Project1].[RegistrationRequestState] AS [RegistrationRequestState], [Project1].[EvaluationDate] AS [EvaluationDate], [Project1].[Score] AS [Score], [Project1].[Reason] AS [Reason], [Project1].[Remark] AS [Remark], [Project1].[RegistrationRequestCode] AS [RegistrationRequestCode], [Project1].[CreatedDate] AS [CreatedDate], [Project1].[CreatedBy] AS [CreatedBy], [Project1].[LastModifiedDate] AS [LastModifiedDate], [Project1].[LastModifiedBy] AS [LastModifiedBy], [Project1].[Id1] AS [Id1], [Project1].[RegistrationRequestBusinessRelationId] AS [RegistrationRequestBusinessRelationId], [Project1].[AuthorizedRepresentativeCompanyName] AS [AuthorizedRepresentativeCompanyName], [Project1].[AuthorizedRepresentativeVatNumber] AS [AuthorizedRepresentativeVatNumber], [Project1].[DeclarationPeriod] AS [DeclarationPeriod], [Project1].[ProfileType] AS [ProfileType], [Project1].[InternetSales] AS [InternetSales], [Project1].[OtherThanInternetSales] AS [OtherThanInternetSales], [Project1].[Id2] AS [Id2], [Project1].[BicAccountNumber] AS [BicAccountNumber], [Project1].[BusinessRelationName] AS [BusinessRelationName], [Project1].[EmailAddress] AS [EmailAddress], [Project1].[Fax] AS [Fax], [Project1].[FoundingDate] AS [FoundingDate], [Project1].[IbanAccountNumber] AS [IbanAccountNumber], [Project1].[LanguageId] AS [LanguageId], [Project1].[FormOfGovernmentId] AS [FormOfGovernmentId], [Project1].[Telephone] AS [Telephone], [Project1].[VatNumber] AS [VatNumber], [Project1].[IsVatObligated] AS [IsVatObligated], [Project1].[BusinessRelationCode] AS [BusinessRelationCode], [Project1].[Id3] AS [Id3], [Project1].[RegistrationRequestBusinessRelationId1] AS [RegistrationRequestBusinessRelationId1], [Project1].[AuthorizedRepresentativeCompanyName1] AS [AuthorizedRepresentativeCompanyName1], [Project1].[AuthorizedRepresentativeVatNumber1] AS [AuthorizedRepresentativeVatNumber1], [Project1].[DeclarationPeriod1] AS [DeclarationPeriod1], [Project1].[ProfileType1] AS [ProfileType1], [Project1].[InternetSales1] AS [InternetSales1], [Project1].[OtherThanInternetSales1] AS [OtherThanInternetSales1], [Project1].[Id4] AS [Id4], [Project1].[BicAccountNumber1] AS [BicAccountNumber1], [Project1].[BusinessRelationName1] AS [BusinessRelationName1], [Project1].[EmailAddress1] AS [EmailAddress1], [Project1].[Fax1] AS [Fax1], [Project1].[FoundingDate1] AS [FoundingDate1], [Project1].[IbanAccountNumber1] AS [IbanAccountNumber1], [Project1].[LanguageId1] AS [LanguageId1], [Project1].[FormOfGovernmentId1] AS [FormOfGovernmentId1], [Project1].[Telephone1] AS [Telephone1], [Project1].[VatNumber1] AS [VatNumber1], [Project1].[IsVatObligated1] AS [IsVatObligated1], [Project1].[BusinessRelationCode1] AS [BusinessRelationCode1], CASE WHEN ([Project1].[Id1] IS NOT NULL) THEN 1 END AS [C1], CASE WHEN ([Project1].[Id2] IS NOT NULL) THEN 1 END AS [C2], [Project1].[C1] AS [C3] FROM ( SELECT [Extent1].[Id] AS [Id], [Extent1].[RegistrationRequestGeneralOriginalId] AS [RegistrationRequestGeneralOriginalId], [Extent1].[RegistrationRequestGeneralId] AS [RegistrationRequestGeneralId], [Extent1].[SignedDate] AS [SignedDate], [Extent1].[RegistrationRequestState] AS [RegistrationRequestState], [Extent1].[EvaluationDate] AS [EvaluationDate], [Extent1].[Score] AS [Score], [Extent1].[Reason] AS [Reason], [Extent1].[Remark] AS [Remark], [Extent1].[RegistrationRequestCode] AS [RegistrationRequestCode], [Extent1].[CreatedDate] AS [CreatedDate], [Extent1].[CreatedBy] AS [CreatedBy], [Extent1].[LastModifiedDate] AS [LastModifiedDate], [Extent1].[LastModifiedBy] AS [LastModifiedBy], [Extent2].[Id] AS [Id1], [Extent2].[RegistrationRequestBusinessRelationId] AS [RegistrationRequestBusinessRelationId], [Extent2].[AuthorizedRepresentativeCompanyName] AS [AuthorizedRepresentativeCompanyName], [Extent2].[AuthorizedRepresentativeVatNumber] AS [AuthorizedRepresentativeVatNumber], [Extent2].[DeclarationPeriod] AS [DeclarationPeriod], [Extent2].[ProfileType] AS [ProfileType], [Extent2].[InternetSales] AS [InternetSales], [Extent2].[OtherThanInternetSales] AS [OtherThanInternetSales], [Extent3].[Id] AS [Id2], [Extent3].[BicAccountNumber] AS [BicAccountNumber], [Extent3].[BusinessRelationName] AS [BusinessRelationName], [Extent3].[EmailAddress] AS [EmailAddress], [Extent3].[Fax] AS [Fax], [Extent3].[FoundingDate] AS [FoundingDate], [Extent3].[IbanAccountNumber] AS [IbanAccountNumber], [Extent3].[LanguageId] AS [LanguageId], [Extent3].[FormOfGovernmentId] AS [FormOfGovernmentId], [Extent3].[Telephone] AS [Telephone], [Extent3].[VatNumber] AS [VatNumber], [Extent3].[IsVatObligated] AS [IsVatObligated], [Extent3].[BusinessRelationCode] AS [BusinessRelationCode], [Extent4].[Id] AS [Id3], [Extent4].[RegistrationRequestBusinessRelationId] AS [RegistrationRequestBusinessRelationId1], [Extent4].[AuthorizedRepresentativeCompanyName] AS [AuthorizedRepresentativeCompanyName1], [Extent4].[AuthorizedRepresentativeVatNumber] AS [AuthorizedRepresentativeVatNumber1], [Extent4].[DeclarationPeriod] AS [DeclarationPeriod1], [Extent4].[ProfileType] AS [ProfileType1], [Extent4].[InternetSales] AS [InternetSales1], [Extent4].[OtherThanInternetSales] AS [OtherThanInternetSales1], [Extent5].[Id] AS [Id4], [Extent5].[BicAccountNumber] AS [BicAccountNumber1], [Extent5].[BusinessRelationName] AS [BusinessRelationName1], [Extent5].[EmailAddress] AS [EmailAddress1], [Extent5].[Fax] AS [Fax1], [Extent5].[FoundingDate] AS [FoundingDate1], [Extent5].[IbanAccountNumber] AS [IbanAccountNumber1], [Extent5].[LanguageId] AS [LanguageId1], [Extent5].[FormOfGovernmentId] AS [FormOfGovernmentId1], [Extent5].[Telephone] AS [Telephone1], [Extent5].[VatNumber] AS [VatNumber1], [Extent5].[IsVatObligated] AS [IsVatObligated1], [Extent5].[BusinessRelationCode] AS [BusinessRelationCode1], (SELECT MIN([Extent6].[FromDate]) AS [A1] FROM [dbo].[RegistrationRequestDeclarationProfile] AS [Extent6] WHERE (([Extent6].[Deleted] = @DynamicFilterParam_000001) ) AND ([Extent1].[Id] = [Extent6].[RegistrationRequestId])) AS [C1] FROM (SELECT [Var_154].[Id] AS [Id], [Var_154].[RegistrationRequestGeneralOriginalId] AS [RegistrationRequestGeneralOriginalId], [Var_154].[RegistrationRequestGeneralId] AS [RegistrationRequestGeneralId], [Var_154].[SignedDate] AS [SignedDate], [Var_154].[RegistrationRequestState] AS [RegistrationRequestState], [Var_154].[EvaluationDate] AS [EvaluationDate], [Var_154].[Score] AS [Score], [Var_154].[Reason] AS [Reason], [Var_154].[Remark] AS [Remark], [Var_154].[RegistrationRequestCode] AS [RegistrationRequestCode], [Var_154].[CreatedDate] AS [CreatedDate], [Var_154].[CreatedBy] AS [CreatedBy], [Var_154].[LastModifiedDate] AS [LastModifiedDate], [Var_154].[LastModifiedBy] AS [LastModifiedBy] FROM [dbo].[RegistrationRequest] AS [Var_154] WHERE ([Var_154].[Deleted] = @DynamicFilterParam_000001) ) AS [Extent1] LEFT OUTER JOIN (SELECT [Var_155].[Id] AS [Id], [Var_155].[RegistrationRequestBusinessRelationId] AS [RegistrationRequestBusinessRelationId], [Var_155].[AuthorizedRepresentativeCompanyName] AS [AuthorizedRepresentativeCompanyName], [Var_155].[AuthorizedRepresentativeVatNumber] AS [AuthorizedRepresentativeVatNumber], [Var_155].[DeclarationPeriod] AS [DeclarationPeriod], [Var_155].[ProfileType] AS [ProfileType], [Var_155].[InternetSales] AS [InternetSales], [Var_155].[OtherThanInternetSales] AS [OtherThanInternetSales] FROM [dbo].[RegistrationRequestGeneral] AS [Var_155] WHERE ([Var_155].[Deleted] = @DynamicFilterParam_000001) ) AS [Extent2] ON [Extent1].[RegistrationRequestGeneralId] = [Extent2].[Id] LEFT OUTER JOIN (SELECT [Var_156].[Id] AS [Id], [Var_156].[BicAccountNumber] AS [BicAccountNumber], [Var_156].[BusinessRelationName] AS [BusinessRelationName], [Var_156].[EmailAddress] AS [EmailAddress], [Var_156].[Fax] AS [Fax], [Var_156].[FoundingDate] AS [FoundingDate], [Var_156].[IbanAccountNumber] AS [IbanAccountNumber], [Var_156].[LanguageId] AS [LanguageId], [Var_156].[FormOfGovernmentId] AS [FormOfGovernmentId], [Var_156].[Telephone] AS [Telephone], [Var_156].[VatNumber] AS [VatNumber], [Var_156].[IsVatObligated] AS [IsVatObligated], [Var_156].[BusinessRelationCode] AS [BusinessRelationCode] FROM [dbo].[RegistrationRequestBusinessRelation] AS [Var_156] WHERE ([Var_156].[Deleted] = @DynamicFilterParam_000001) ) AS [Extent3] ON [Extent2].[RegistrationRequestBusinessRelationId] = [Extent3].[Id] INNER JOIN (SELECT [Var_157].[Id] AS [Id], [Var_157].[RegistrationRequestBusinessRelationId] AS [RegistrationRequestBusinessRelationId], [Var_157].[AuthorizedRepresentativeCompanyName] AS [AuthorizedRepresentativeCompanyName], [Var_157].[AuthorizedRepresentativeVatNumber] AS [AuthorizedRepresentativeVatNumber], [Var_157].[DeclarationPeriod] AS [DeclarationPeriod], [Var_157].[ProfileType] AS [ProfileType], [Var_157].[InternetSales] AS [InternetSales], [Var_157].[OtherThanInternetSales] AS [OtherThanInternetSales] FROM [dbo].[RegistrationRequestGeneral] AS [Var_157] WHERE ([Var_157].[Deleted] = @DynamicFilterParam_000001) ) AS [Extent4] ON [Extent1].[RegistrationRequestGeneralOriginalId] = [Extent4].[Id] INNER JOIN (SELECT [Var_158].[Id] AS [Id], [Var_158].[BicAccountNumber] AS [BicAccountNumber], [Var_158].[BusinessRelationName] AS [BusinessRelationName], [Var_158].[EmailAddress] AS [EmailAddress], [Var_158].[Fax] AS [Fax], [Var_158].[FoundingDate] AS [FoundingDate], [Var_158].[IbanAccountNumber] AS [IbanAccountNumber], [Var_158].[LanguageId] AS [LanguageId], [Var_158].[FormOfGovernmentId] AS [FormOfGovernmentId], [Var_158].[Telephone] AS [Telephone], [Var_158].[VatNumber] AS [VatNumber], [Var_158].[IsVatObligated] AS [IsVatObligated], [Var_158].[BusinessRelationCode] AS [BusinessRelationCode] FROM [dbo].[RegistrationRequestBusinessRelation] AS [Var_158] WHERE ([Var_158].[Deleted] = @DynamicFilterParam_000001) ) AS [Extent5] ON [Extent4].[RegistrationRequestBusinessRelationId] = [Extent5].[Id] WHERE [Extent1].[Id] = @p__linq__0 ) AS [Project1] ) AS [Limit1] LEFT OUTER JOIN (SELECT [Extent7].[Id] AS [Id1], [Extent7].[RegistrationRequestId] AS [RegistrationRequestId], [Extent7].[AttachmentId] AS [AttachmentId], [Extent7].[IsSigned] AS [IsSigned], [Extent8].[Id] AS [Id2], [Extent8].[Name] AS [Name], [Extent8].[DocumentPath] AS [DocumentPath], [Extent8].[CreatedDate] AS [CreatedDate1], [Extent8].[CreatedBy] AS [CreatedBy1], [Extent8].[LastModifiedDate] AS [LastModifiedDate1], [Extent8].[LastModifiedBy] AS [LastModifiedBy1] FROM (SELECT [Var_159].[Id] AS [Id], [Var_159].[RegistrationRequestId] AS [RegistrationRequestId], [Var_159].[AttachmentId] AS [AttachmentId], [Var_159].[IsSigned] AS [IsSigned] FROM [dbo].[RegistrationRequestAttachment] AS [Var_159] WHERE ([Var_159].[Deleted] = @DynamicFilterParam_000001) ) AS [Extent7] INNER JOIN (SELECT [Var_160].[Id] AS [Id], [Var_160].[Name] AS [Name], [Var_160].[DocumentPath] AS [DocumentPath], [Var_160].[CreatedDate] AS [CreatedDate], [Var_160].[CreatedBy] AS [CreatedBy], [Var_160].[LastModifiedDate] AS [LastModifiedDate], [Var_160].[LastModifiedBy] AS [LastModifiedBy] FROM [dbo].[Attachment] AS [Var_160] WHERE ([Var_160].[Deleted] = @DynamicFilterParam_000001) ) AS [Extent8] ON [Extent7].[AttachmentId] = [Extent8].[Id] ) AS [Join5] ON [Limit1].[Id] = [Join5].[RegistrationRequestId] UNION ALL SELECT 2 AS [C1], [Limit2].[Id1] AS [Id], [Limit2].[Id2] AS [Id1], [Limit2].[Id3] AS [Id2], [Limit2].[Id4] AS [Id3], [Limit2].[Score] AS [Score], [Limit2].[RegistrationRequestCode] AS [RegistrationRequestCode], [Limit2].[SignedDate] AS [SignedDate], [Limit2].[RegistrationRequestState] AS [RegistrationRequestState], [Limit2].[EvaluationDate] AS [EvaluationDate], [Limit2].[Score] AS [Score1], [Limit2].[Reason] AS [Reason], [Limit2].[Remark] AS [Remark], [Limit2].[C1] AS [C2], [Limit2].[AuthorizedRepresentativeCompanyName] AS [AuthorizedRepresentativeCompanyName], [Limit2].[AuthorizedRepresentativeVatNumber] AS [AuthorizedRepresentativeVatNumber], [Limit2].[DeclarationPeriod] AS [DeclarationPeriod], [Limit2].[ProfileType] AS [ProfileType], [Limit2].[InternetSales] AS [InternetSales], [Limit2].[OtherThanInternetSales] AS [OtherThanInternetSales], [Limit2].[C2] AS [C3], [Limit2].[BusinessRelationCode] AS [BusinessRelationCode], [Limit2].[BicAccountNumber] AS [BicAccountNumber], [Limit2].[BusinessRelationName] AS [BusinessRelationName], [Limit2].[EmailAddress] AS [EmailAddress], [Limit2].[Fax] AS [Fax], [Limit2].[FoundingDate] AS [FoundingDate], [Limit2].[IbanAccountNumber] AS [IbanAccountNumber], [Limit2].[Telephone] AS [Telephone], [Limit2].[VatNumber] AS [VatNumber], [Limit2].[IsVatObligated] AS [IsVatObligated], [Limit2].[LanguageId] AS [LanguageId], [Limit2].[FormOfGovernmentId] AS [FormOfGovernmentId], [Limit2].[RegistrationRequestBusinessRelationId] AS [RegistrationRequestBusinessRelationId], [Limit2].[RegistrationRequestGeneralId] AS [RegistrationRequestGeneralId], [Limit2].[Score] AS [Score2], [Limit2].[AuthorizedRepresentativeCompanyName1] AS [AuthorizedRepresentativeCompanyName1], [Limit2].[AuthorizedRepresentativeVatNumber1] AS [AuthorizedRepresentativeVatNumber1], [Limit2].[DeclarationPeriod1] AS [DeclarationPeriod1], [Limit2].[ProfileType1] AS [ProfileType1], [Limit2].[InternetSales1] AS [InternetSales1], [Limit2].[OtherThanInternetSales1] AS [OtherThanInternetSales1], [Limit2].[Score] AS [Score3], [Limit2].[BusinessRelationCode1] AS [BusinessRelationCode1], [Limit2].[BicAccountNumber1] AS [BicAccountNumber1], [Limit2].[BusinessRelationName1] AS [BusinessRelationName1], [Limit2].[EmailAddress1] AS [EmailAddress1], [Limit2].[Fax1] AS [Fax1], [Limit2].[FoundingDate1] AS [FoundingDate1], [Limit2].[IbanAccountNumber1] AS [IbanAccountNumber1], [Limit2].[Telephone1] AS [Telephone1], [Limit2].[VatNumber1] AS [VatNumber1], [Limit2].[IsVatObligated1] AS [IsVatObligated1], [Limit2].[LanguageId1] AS [LanguageId1], [Limit2].[FormOfGovernmentId1] AS [FormOfGovernmentId1], [Limit2].[RegistrationRequestBusinessRelationId1] AS [RegistrationRequestBusinessRelationId1], [Limit2].[RegistrationRequestGeneralOriginalId] AS [RegistrationRequestGeneralOriginalId], [Limit2].[CreatedDate] AS [CreatedDate], [Limit2].[CreatedBy] AS [CreatedBy], [Limit2].[LastModifiedDate] AS [LastModifiedDate], [Limit2].[LastModifiedBy] AS [LastModifiedBy], [Limit2].[Id] AS [Id4], [Limit2].[C3] AS [C4], CAST(NULL AS int) AS [C5], CAST(NULL AS bit) AS [C6], CAST(NULL AS int) AS [C7], CAST(NULL AS varchar(1)) AS [C8], CAST(NULL AS varchar(1)) AS [C9], CAST(NULL AS datetime2) AS [C10], CAST(NULL AS varchar(1)) AS [C11], CAST(NULL AS datetime2) AS [C12], CAST(NULL AS varchar(1)) AS [C13], CAST(NULL AS uniqueidentifier) AS [C14], CAST(NULL AS uniqueidentifier) AS [C15], [Join11].[FunctionTitleId] AS [FunctionTitleId], [Join11].[FunctionTitleId] AS [FunctionTitleId1], [Join11].[FunctionTitleId] AS [FunctionTitleId2], [Join11].[FirstName] AS [FirstName], [Join11].[LastName] AS [LastName], [Join11].[EmailAddress] AS [EmailAddress2], [Join11].[Telephone1] AS [Telephone11], [Join11].[Telephone2] AS [Telephone2], [Join11].[TitleBusinessCard] AS [TitleBusinessCard], [Join11].[GenderId] AS [GenderId], [Join11].[LanguageId] AS [LanguageId2], [Join11].[RegistrationRequestContactPersonId] AS [RegistrationRequestContactPersonId], [Join11].[Id3] AS [Id5], CAST(NULL AS int) AS [C16], CAST(NULL AS int) AS [C17], CAST(NULL AS int) AS [C18], CAST(NULL AS varchar(1)) AS [C19], CAST(NULL AS varchar(1)) AS [C20], CAST(NULL AS varchar(1)) AS [C21], CAST(NULL AS varchar(1)) AS [C22], CAST(NULL AS varchar(1)) AS [C23], CAST(NULL AS varchar(1)) AS [C24], CAST(NULL AS int) AS [C25], CAST(NULL AS int) AS [C26], CAST(NULL AS uniqueidentifier) AS [C27], CAST(NULL AS uniqueidentifier) AS [C28], CAST(NULL AS int) AS [C29], CAST(NULL AS int) AS [C30], CAST(NULL AS int) AS [C31], CAST(NULL AS varchar(1)) AS [C32], CAST(NULL AS varchar(1)) AS [C33], CAST(NULL AS varchar(1)) AS [C34], CAST(NULL AS varchar(1)) AS [C35], CAST(NULL AS varchar(1)) AS [C36], CAST(NULL AS varchar(1)) AS [C37], CAST(NULL AS int) AS [C38], CAST(NULL AS int) AS [C39], CAST(NULL AS uniqueidentifier) AS [C40], CAST(NULL AS uniqueidentifier) AS [C41], CAST(NULL AS int) AS [C42], CAST(NULL AS int) AS [C43], CAST(NULL AS int) AS [C44], CAST(NULL AS varchar(1)) AS [C45], CAST(NULL AS varchar(1)) AS [C46], CAST(NULL AS varchar(1)) AS [C47], CAST(NULL AS varchar(1)) AS [C48], CAST(NULL AS varchar(1)) AS [C49], CAST(NULL AS varchar(1)) AS [C50], CAST(NULL AS int) AS [C51], CAST(NULL AS int) AS [C52], CAST(NULL AS uniqueidentifier) AS [C53], CAST(NULL AS uniqueidentifier) AS [C54] FROM (SELECT TOP (1) [Project4].[Id] AS [Id], [Project4].[RegistrationRequestGeneralOriginalId] AS [RegistrationRequestGeneralOriginalId], [Project4].[RegistrationRequestGeneralId] AS [RegistrationRequestGeneralId], [Project4].[SignedDate] AS [SignedDate], [Project4].[RegistrationRequestState] AS [RegistrationRequestState], [Project4].[EvaluationDate] AS [EvaluationDate], [Project4].[Score] AS [Score], [Project4].[Reason] AS [Reason], [Project4].[Remark] AS [Remark], [Project4].[RegistrationRequestCode] AS [RegistrationRequestCode], [Project4].[CreatedDate] AS [CreatedDate], [Project4].[CreatedBy] AS [CreatedBy], [Project4].[LastModifiedDate] AS [LastModifiedDate], [Project4].[LastModifiedBy] AS [LastModifiedBy], [Project4].[Id1] AS [Id1], [Project4].[RegistrationRequestBusinessRelationId] AS [RegistrationRequestBusinessRelationId], [Project4].[AuthorizedRepresentativeCompanyName] AS [AuthorizedRepresentativeCompanyName], [Project4].[AuthorizedRepresentativeVatNumber] AS [AuthorizedRepresentativeVatNumber], [Project4].[DeclarationPeriod] AS [DeclarationPeriod], [Project4].[ProfileType] AS [ProfileType], [Project4].[InternetSales] AS [InternetSales], [Project4].[OtherThanInternetSales] AS [OtherThanInternetSales], [Project4].[Id2] AS [Id2], [Project4].[BicAccountNumber] AS [BicAccountNumber], [Project4].[BusinessRelationName] AS [BusinessRelationName], [Project4].[EmailAddress] AS [EmailAddress], [Project4].[Fax] AS [Fax], [Project4].[FoundingDate] AS [FoundingDate], [Project4].[IbanAccountNumber] AS [IbanAccountNumber], [Project4].[LanguageId] AS [LanguageId], [Project4].[FormOfGovernmentId] AS [FormOfGovernmentId], [Project4].[Telephone] AS [Telephone], [Project4].[VatNumber] AS [VatNumber], [Project4].[IsVatObligated] AS [IsVatObligated], [Project4].[BusinessRelationCode] AS [BusinessRelationCode], [Project4].[Id3] AS [Id3], [Project4].[RegistrationRequestBusinessRelationId1] AS [RegistrationRequestBusinessRelationId1], [Project4].[AuthorizedRepresentativeCompanyName1] AS [AuthorizedRepresentativeCompanyName1], [Project4].[AuthorizedRepresentativeVatNumber1] AS [AuthorizedRepresentativeVatNumber1], [Project4].[DeclarationPeriod1] AS [DeclarationPeriod1], [Project4].[ProfileType1] AS [ProfileType1], [Project4].[InternetSales1] AS [InternetSales1], [Project4].[OtherThanInternetSales1] AS [OtherThanInternetSales1], [Project4].[Id4] AS [Id4], [Project4].[BicAccountNumber1] AS [BicAccountNumber1], [Project4].[BusinessRelationName1] AS [BusinessRelationName1], [Project4].[EmailAddress1] AS [EmailAddress1], [Project4].[Fax1] AS [Fax1], [Project4].[FoundingDate1] AS [FoundingDate1], [Project4].[IbanAccountNumber1] AS [IbanAccountNumber1], [Project4].[LanguageId1] AS [LanguageId1], [Project4].[FormOfGovernmentId1] AS [FormOfGovernmentId1], [Project4].[Telephone1] AS [Telephone1], [Project4].[VatNumber1] AS [VatNumber1], [Project4].[IsVatObligated1] AS [IsVatObligated1], [Project4].[BusinessRelationCode1] AS [BusinessRelationCode1], CASE WHEN ([Project4].[Id1] IS NOT NULL) THEN 1 END AS [C1], CASE WHEN ([Project4].[Id2] IS NOT NULL) THEN 1 END AS [C2], [Project4].[C1] AS [C3] FROM ( SELECT [Extent9].[Id] AS [Id], [Extent9].[RegistrationRequestGeneralOriginalId] AS [RegistrationRequestGeneralOriginalId], [Extent9].[RegistrationRequestGeneralId] AS [RegistrationRequestGeneralId], [Extent9].[SignedDate] AS [SignedDate], [Extent9].[RegistrationRequestState] AS [RegistrationRequestState], [Extent9].[EvaluationDate] AS [EvaluationDate], [Extent9].[Score] AS [Score], [Extent9].[Reason] AS [Reason], [Extent9].[Remark] AS [Remark], [Extent9].[RegistrationRequestCode] AS [RegistrationRequestCode], [Extent9].[CreatedDate] AS [CreatedDate], [Extent9].[CreatedBy] AS [CreatedBy], [Extent9].[LastModifiedDate] AS [LastModifiedDate], [Extent9].[LastModifiedBy] AS [LastModifiedBy], [Extent10].[Id] AS [Id1], [Extent10].[RegistrationRequestBusinessRelationId] AS [RegistrationRequestBusinessRelationId], [Extent10].[AuthorizedRepresentativeCompanyName] AS [AuthorizedRepresentativeCompanyName], [Extent10].[AuthorizedRepresentativeVatNumber] AS [AuthorizedRepresentativeVatNumber], [Extent10].[DeclarationPeriod] AS [DeclarationPeriod], [Extent10].[ProfileType] AS [ProfileType], [Extent10].[InternetSales] AS [InternetSales], [Extent10].[OtherThanInternetSales] AS [OtherThanInternetSales], [Extent11].[Id] AS [Id2], [Extent11].[BicAccountNumber] AS [BicAccountNumber], [Extent11].[BusinessRelationName] AS [BusinessRelationName], [Extent11].[EmailAddress] AS [EmailAddress], [Extent11].[Fax] AS [Fax], [Extent11].[FoundingDate] AS [FoundingDate], [Extent11].[IbanAccountNumber] AS [IbanAccountNumber], [Extent11].[LanguageId] AS [LanguageId], [Extent11].[FormOfGovernmentId] AS [FormOfGovernmentId], [Extent11].[Telephone] AS [Telephone], [Extent11].[VatNumber] AS [VatNumber], [Extent11].[IsVatObligated] AS [IsVatObligated], [Extent11].[BusinessRelationCode] AS [BusinessRelationCode], [Extent12].[Id] AS [Id3], [Extent12].[RegistrationRequestBusinessRelationId] AS [RegistrationRequestBusinessRelationId1], [Extent12].[AuthorizedRepresentativeCompanyName] AS [AuthorizedRepresentativeCompanyName1], [Extent12].[AuthorizedRepresentativeVatNumber] AS [AuthorizedRepresentativeVatNumber1], [Extent12].[DeclarationPeriod] AS [DeclarationPeriod1], [Extent12].[ProfileType] AS [ProfileType1], [Extent12].[InternetSales] AS [InternetSales1], [Extent12].[OtherThanInternetSales] AS [OtherThanInternetSales1], [Extent13].[Id] AS [Id4], [Extent13].[BicAccountNumber] AS [BicAccountNumber1], [Extent13].[BusinessRelationName] AS [BusinessRelationName1], [Extent13].[EmailAddress] AS [EmailAddress1], [Extent13].[Fax] AS [Fax1], [Extent13].[FoundingDate] AS [FoundingDate1], [Extent13].[IbanAccountNumber] AS [IbanAccountNumber1], [Extent13].[LanguageId] AS [LanguageId1], [Extent13].[FormOfGovernmentId] AS [FormOfGovernmentId1], [Extent13].[Telephone] AS [Telephone1], [Extent13].[VatNumber] AS [VatNumber1], [Extent13].[IsVatObligated] AS [IsVatObligated1], [Extent13].[BusinessRelationCode] AS [BusinessRelationCode1], (SELECT MIN([Extent14].[FromDate]) AS [A1] FROM [dbo].[RegistrationRequestDeclarationProfile] AS [Extent14] WHERE (([Extent14].[Deleted] = @DynamicFilterParam_000001) ) AND ([Extent9].[Id] = [Extent14].[RegistrationRequestId])) AS [C1] FROM (SELECT [Var_161].[Id] AS [Id], [Var_161].[RegistrationRequestGeneralOriginalId] AS [RegistrationRequestGeneralOriginalId], [Var_161].[RegistrationRequestGeneralId] AS [RegistrationRequestGeneralId], [Var_161].[SignedDate] AS [SignedDate], [Var_161].[RegistrationRequestState] AS [RegistrationRequestState], [Var_161].[EvaluationDate] AS [EvaluationDate], [Var_161].[Score] AS [Score], [Var_161].[Reason] AS [Reason], [Var_161].[Remark] AS [Remark], [Var_161].[RegistrationRequestCode] AS [RegistrationRequestCode], [Var_161].[CreatedDate] AS [CreatedDate], [Var_161].[CreatedBy] AS [CreatedBy], [Var_161].[LastModifiedDate] AS [LastModifiedDate], [Var_161].[LastModifiedBy] AS [LastModifiedBy] FROM [dbo].[RegistrationRequest] AS [Var_161] WHERE ([Var_161].[Deleted] = @DynamicFilterParam_000001) ) AS [Extent9] LEFT OUTER JOIN (SELECT [Var_162].[Id] AS [Id], [Var_162].[RegistrationRequestBusinessRelationId] AS [RegistrationRequestBusinessRelationId], [Var_162].[AuthorizedRepresentativeCompanyName] AS [AuthorizedRepresentativeCompanyName], [Var_162].[AuthorizedRepresentativeVatNumber] AS [AuthorizedRepresentativeVatNumber], [Var_162].[DeclarationPeriod] AS [DeclarationPeriod], [Var_162].[ProfileType] AS [ProfileType], [Var_162].[InternetSales] AS [InternetSales], [Var_162].[OtherThanInternetSales] AS [OtherThanInternetSales] FROM [dbo].[RegistrationRequestGeneral] AS [Var_162] WHERE ([Var_162].[Deleted] = @DynamicFilterParam_000001) ) AS [Extent10] ON [Extent9].[RegistrationRequestGeneralId] = [Extent10].[Id] LEFT OUTER JOIN (SELECT [Var_163].[Id] AS [Id], [Var_163].[BicAccountNumber] AS [BicAccountNumber], [Var_163].[BusinessRelationName] AS [BusinessRelationName], [Var_163].[EmailAddress] AS [EmailAddress], [Var_163].[Fax] AS [Fax], [Var_163].[FoundingDate] AS [FoundingDate], [Var_163].[IbanAccountNumber] AS [IbanAccountNumber], [Var_163].[LanguageId] AS [LanguageId], [Var_163].[FormOfGovernmentId] AS [FormOfGovernmentId], [Var_163].[Telephone] AS [Telephone], [Var_163].[VatNumber] AS [VatNumber], [Var_163].[IsVatObligated] AS [IsVatObligated], [Var_163].[BusinessRelationCode] AS [BusinessRelationCode] FROM [dbo].[RegistrationRequestBusinessRelation] AS [Var_163] WHERE ([Var_163].[Deleted] = @DynamicFilterParam_000001) ) AS [Extent11] ON [Extent10].[RegistrationRequestBusinessRelationId] = [Extent11].[Id] INNER JOIN (SELECT [Var_164].[Id] AS [Id], [Var_164].[RegistrationRequestBusinessRelationId] AS [RegistrationRequestBusinessRelationId], [Var_164].[AuthorizedRepresentativeCompanyName] AS [AuthorizedRepresentativeCompanyName], [Var_164].[AuthorizedRepresentativeVatNumber] AS [AuthorizedRepresentativeVatNumber], [Var_164].[DeclarationPeriod] AS [DeclarationPeriod], [Var_164].[ProfileType] AS [ProfileType], [Var_164].[InternetSales] AS [InternetSales], [Var_164].[OtherThanInternetSales] AS [OtherThanInternetSales] FROM [dbo].[RegistrationRequestGeneral] AS [Var_164] WHERE ([Var_164].[Deleted] = @DynamicFilterParam_000001) ) AS [Extent12] ON [Extent9].[RegistrationRequestGeneralOriginalId] = [Extent12].[Id] INNER JOIN (SELECT [Var_165].[Id] AS [Id], [Var_165].[BicAccountNumber] AS [BicAccountNumber], [Var_165].[BusinessRelationName] AS [BusinessRelationName], [Var_165].[EmailAddress] AS [EmailAddress], [Var_165].[Fax] AS [Fax], [Var_165].[FoundingDate] AS [FoundingDate], [Var_165].[IbanAccountNumber] AS [IbanAccountNumber], [Var_165].[LanguageId] AS [LanguageId], [Var_165].[FormOfGovernmentId] AS [FormOfGovernmentId], [Var_165].[Telephone] AS [Telephone], [Var_165].[VatNumber] AS [VatNumber], [Var_165].[IsVatObligated] AS [IsVatObligated], [Var_165].[BusinessRelationCode] AS [BusinessRelationCode] FROM [dbo].[RegistrationRequestBusinessRelation] AS [Var_165] WHERE ([Var_165].[Deleted] = @DynamicFilterParam_000001) ) AS [Extent13] ON [Extent12].[RegistrationRequestBusinessRelationId] = [Extent13].[Id] WHERE [Extent9].[Id] = @p__linq__0 ) AS [Project4] ) AS [Limit2] INNER JOIN (SELECT [Extent15].[Id] AS [Id3], [Extent15].[RegistrationRequestGeneralId] AS [RegistrationRequestGeneralId], [Extent15].[RegistrationRequestContactPersonId] AS [RegistrationRequestContactPersonId], [Extent15].[FunctionTitleId] AS [FunctionTitleId], [Extent16].[Id] AS [Id4], [Extent16].[FirstName] AS [FirstName], [Extent16].[LastName] AS [LastName], [Extent16].[EmailAddress] AS [EmailAddress], [Extent16].[Telephone1] AS [Telephone1], [Extent16].[Telephone2] AS [Telephone2], [Extent16].[GenderId] AS [GenderId], [Extent16].[LanguageId] AS [LanguageId], [Extent16].[TitleBusinessCard] AS [TitleBusinessCard] FROM (SELECT [Var_166].[Id] AS [Id], [Var_166].[RegistrationRequestGeneralId] AS [RegistrationRequestGeneralId], [Var_166].[RegistrationRequestContactPersonId] AS [RegistrationRequestContactPersonId], [Var_166].[FunctionTitleId] AS [FunctionTitleId] FROM [dbo].[RegistrationRequestGeneralContactPerson] AS [Var_166] WHERE ([Var_166].[Deleted] = @DynamicFilterParam_000001) ) AS [Extent15] INNER JOIN (SELECT [Var_167].[Id] AS [Id], [Var_167].[FirstName] AS [FirstName], [Var_167].[LastName] AS [LastName], [Var_167].[EmailAddress] AS [EmailAddress], [Var_167].[Telephone1] AS [Telephone1], [Var_167].[Telephone2] AS [Telephone2], [Var_167].[GenderId] AS [GenderId], [Var_167].[LanguageId] AS [LanguageId], [Var_167].[TitleBusinessCard] AS [TitleBusinessCard] FROM [dbo].[RegistrationRequestContactPerson] AS [Var_167] WHERE ([Var_167].[Deleted] = @DynamicFilterParam_000001) ) AS [Extent16] ON [Extent15].[RegistrationRequestContactPersonId] = [Extent16].[Id] ) AS [Join11] ON [Limit2].[RegistrationRequestGeneralId] = [Join11].[RegistrationRequestGeneralId] UNION ALL SELECT 3 AS [C1], [Limit3].[Id1] AS [Id], [Limit3].[Id2] AS [Id1], [Limit3].[Id3] AS [Id2], [Limit3].[Id4] AS [Id3], [Limit3].[Score] AS [Score], [Limit3].[RegistrationRequestCode] AS [RegistrationRequestCode], [Limit3].[SignedDate] AS [SignedDate], [Limit3].[RegistrationRequestState] AS [RegistrationRequestState], [Limit3].[EvaluationDate] AS [EvaluationDate], [Limit3].[Score] AS [Score1], [Limit3].[Reason] AS [Reason], [Limit3].[Remark] AS [Remark], [Limit3].[C1] AS [C2], [Limit3].[AuthorizedRepresentativeCompanyName] AS [AuthorizedRepresentativeCompanyName], [Limit3].[AuthorizedRepresentativeVatNumber] AS [AuthorizedRepresentativeVatNumber], [Limit3].[DeclarationPeriod] AS [DeclarationPeriod], [Limit3].[ProfileType] AS [ProfileType], [Limit3].[InternetSales] AS [InternetSales], [Limit3].[OtherThanInternetSales] AS [OtherThanInternetSales], [Limit3].[C2] AS [C3], [Limit3].[BusinessRelationCode] AS [BusinessRelationCode], [Limit3].[BicAccountNumber] AS [BicAccountNumber], [Limit3].[BusinessRelationName] AS [BusinessRelationName], [Limit3].[EmailAddress] AS [EmailAddress], [Limit3].[Fax] AS [Fax], [Limit3].[FoundingDate] AS [FoundingDate], [Limit3].[IbanAccountNumber] AS [IbanAccountNumber], [Limit3].[Telephone] AS [Telephone], [Limit3].[VatNumber] AS [VatNumber], [Limit3].[IsVatObligated] AS [IsVatObligated], [Limit3].[LanguageId] AS [LanguageId], [Limit3].[FormOfGovernmentId] AS [FormOfGovernmentId], [Limit3].[RegistrationRequestBusinessRelationId] AS [RegistrationRequestBusinessRelationId], [Limit3].[RegistrationRequestGeneralId] AS [RegistrationRequestGeneralId], [Limit3].[Score] AS [Score2], [Limit3].[AuthorizedRepresentativeCompanyName1] AS [AuthorizedRepresentativeCompanyName1], [Limit3].[AuthorizedRepresentativeVatNumber1] AS [AuthorizedRepresentativeVatNumber1], [Limit3].[DeclarationPeriod1] AS [DeclarationPeriod1], [Limit3].[ProfileType1] AS [ProfileType1], [Limit3].[InternetSales1] AS [InternetSales1], [Limit3].[OtherThanInternetSales1] AS [OtherThanInternetSales1], [Limit3].[Score] AS [Score3], [Limit3].[BusinessRelationCode1] AS [BusinessRelationCode1], [Limit3].[BicAccountNumber1] AS [BicAccountNumber1], [Limit3].[BusinessRelationName1] AS [BusinessRelationName1], [Limit3].[EmailAddress1] AS [EmailAddress1], [Limit3].[Fax1] AS [Fax1], [Limit3].[FoundingDate1] AS [FoundingDate1], [Limit3].[IbanAccountNumber1] AS [IbanAccountNumber1], [Limit3].[Telephone1] AS [Telephone1], [Limit3].[VatNumber1] AS [VatNumber1], [Limit3].[IsVatObligated1] AS [IsVatObligated1], [Limit3].[LanguageId1] AS [LanguageId1], [Limit3].[FormOfGovernmentId1] AS [FormOfGovernmentId1], [Limit3].[RegistrationRequestBusinessRelationId1] AS [RegistrationRequestBusinessRelationId1], [Limit3].[RegistrationRequestGeneralOriginalId] AS [RegistrationRequestGeneralOriginalId], [Limit3].[CreatedDate] AS [CreatedDate], [Limit3].[CreatedBy] AS [CreatedBy], [Limit3].[LastModifiedDate] AS [LastModifiedDate], [Limit3].[LastModifiedBy] AS [LastModifiedBy], [Limit3].[Id] AS [Id4], [Limit3].[C3] AS [C4], CAST(NULL AS int) AS [C5], CAST(NULL AS bit) AS [C6], CAST(NULL AS int) AS [C7], CAST(NULL AS varchar(1)) AS [C8], CAST(NULL AS varchar(1)) AS [C9], CAST(NULL AS datetime2) AS [C10], CAST(NULL AS varchar(1)) AS [C11], CAST(NULL AS datetime2) AS [C12], CAST(NULL AS varchar(1)) AS [C13], CAST(NULL AS uniqueidentifier) AS [C14], CAST(NULL AS uniqueidentifier) AS [C15], CAST(NULL AS int) AS [C16], CAST(NULL AS int) AS [C17], CAST(NULL AS int) AS [C18], CAST(NULL AS varchar(1)) AS [C19], CAST(NULL AS varchar(1)) AS [C20], CAST(NULL AS varchar(1)) AS [C21], CAST(NULL AS varchar(1)) AS [C22], CAST(NULL AS varchar(1)) AS [C23], CAST(NULL AS varchar(1)) AS [C24], CAST(NULL AS int) AS [C25], CAST(NULL AS int) AS [C26], CAST(NULL AS uniqueidentifier) AS [C27], CAST(NULL AS uniqueidentifier) AS [C28], [Join17].[LocationTypeId] AS [LocationTypeId], [Join17].[LocationTypeId] AS [LocationTypeId1], [Join17].[LocationTypeId] AS [LocationTypeId2], [Join17].[Street1] AS [Street1], [Join17].[Street2] AS [Street2], [Join17].[HouseNumber] AS [HouseNumber], [Join17].[HouseNumberAddition] AS [HouseNumberAddition], [Join17].[PostalCode] AS [PostalCode], [Join17].[City] AS [City], [Join17].[CityId] AS [CityId], [Join17].[CountryId] AS [CountryId], [Join17].[RegistrationRequestAddressId] AS [RegistrationRequestAddressId], [Join17].[Id5] AS [Id5], CAST(NULL AS int) AS [C29], CAST(NULL AS int) AS [C30], CAST(NULL AS int) AS [C31], CAST(NULL AS varchar(1)) AS [C32], CAST(NULL AS varchar(1)) AS [C33], CAST(NULL AS varchar(1)) AS [C34], CAST(NULL AS varchar(1)) AS [C35], CAST(NULL AS varchar(1)) AS [C36], CAST(NULL AS varchar(1)) AS [C37], CAST(NULL AS int) AS [C38], CAST(NULL AS int) AS [C39], CAST(NULL AS uniqueidentifier) AS [C40], CAST(NULL AS uniqueidentifier) AS [C41], CAST(NULL AS int) AS [C42], CAST(NULL AS int) AS [C43], CAST(NULL AS int) AS [C44], CAST(NULL AS varchar(1)) AS [C45], CAST(NULL AS varchar(1)) AS [C46], CAST(NULL AS varchar(1)) AS [C47], CAST(NULL AS varchar(1)) AS [C48], CAST(NULL AS varchar(1)) AS [C49], CAST(NULL AS varchar(1)) AS [C50], CAST(NULL AS int) AS [C51], CAST(NULL AS int) AS [C52], CAST(NULL AS uniqueidentifier) AS [C53], CAST(NULL AS uniqueidentifier) AS [C54] FROM (SELECT TOP (1) [Project7].[Id] AS [Id], [Project7].[RegistrationRequestGeneralOriginalId] AS [RegistrationRequestGeneralOriginalId], [Project7].[RegistrationRequestGeneralId] AS [RegistrationRequestGeneralId], [Project7].[SignedDate] AS [SignedDate], [Project7].[RegistrationRequestState] AS [RegistrationRequestState], [Project7].[EvaluationDate] AS [EvaluationDate], [Project7].[Score] AS [Score], [Project7].[Reason] AS [Reason], [Project7].[Remark] AS [Remark], [Project7].[RegistrationRequestCode] AS [RegistrationRequestCode], [Project7].[CreatedDate] AS [CreatedDate], [Project7].[CreatedBy] AS [CreatedBy], [Project7].[LastModifiedDate] AS [LastModifiedDate], [Project7].[LastModifiedBy] AS [LastModifiedBy], [Project7].[Id1] AS [Id1], [Project7].[RegistrationRequestBusinessRelationId] AS [RegistrationRequestBusinessRelationId], [Project7].[AuthorizedRepresentativeCompanyName] AS [AuthorizedRepresentativeCompanyName], [Project7].[AuthorizedRepresentativeVatNumber] AS [AuthorizedRepresentativeVatNumber], [Project7].[DeclarationPeriod] AS [DeclarationPeriod], [Project7].[ProfileType] AS [ProfileType], [Project7].[InternetSales] AS [InternetSales], [Project7].[OtherThanInternetSales] AS [OtherThanInternetSales], [Project7].[Id2] AS [Id2], [Project7].[BicAccountNumber] AS [BicAccountNumber], [Project7].[BusinessRelationName] AS [BusinessRelationName], [Project7].[EmailAddress] AS [EmailAddress], [Project7].[Fax] AS [Fax], [Project7].[FoundingDate] AS [FoundingDate], [Project7].[IbanAccountNumber] AS [IbanAccountNumber], [Project7].[LanguageId] AS [LanguageId], [Project7].[FormOfGovernmentId] AS [FormOfGovernmentId], [Project7].[Telephone] AS [Telephone], [Project7].[VatNumber] AS [VatNumber], [Project7].[IsVatObligated] AS [IsVatObligated], [Project7].[BusinessRelationCode] AS [BusinessRelationCode], [Project7].[Id3] AS [Id3], [Project7].[RegistrationRequestBusinessRelationId1] AS [RegistrationRequestBusinessRelationId1], [Project7].[AuthorizedRepresentativeCompanyName1] AS [AuthorizedRepresentativeCompanyName1], [Project7].[AuthorizedRepresentativeVatNumber1] AS [AuthorizedRepresentativeVatNumber1], [Project7].[DeclarationPeriod1] AS [DeclarationPeriod1], [Project7].[ProfileType1] AS [ProfileType1], [Project7].[InternetSales1] AS [InternetSales1], [Project7].[OtherThanInternetSales1] AS [OtherThanInternetSales1], [Project7].[Id4] AS [Id4], [Project7].[BicAccountNumber1] AS [BicAccountNumber1], [Project7].[BusinessRelationName1] AS [BusinessRelationName1], [Project7].[EmailAddress1] AS [EmailAddress1], [Project7].[Fax1] AS [Fax1], [Project7].[FoundingDate1] AS [FoundingDate1], [Project7].[IbanAccountNumber1] AS [IbanAccountNumber1], [Project7].[LanguageId1] AS [LanguageId1], [Project7].[FormOfGovernmentId1] AS [FormOfGovernmentId1], [Project7].[Telephone1] AS [Telephone1], [Project7].[VatNumber1] AS [VatNumber1], [Project7].[IsVatObligated1] AS [IsVatObligated1], [Project7].[BusinessRelationCode1] AS [BusinessRelationCode1], CASE WHEN ([Project7].[Id1] IS NOT NULL) THEN 1 END AS [C1], CASE WHEN ([Project7].[Id2] IS NOT NULL) THEN 1 END AS [C2], [Project7].[C1] AS [C3] FROM ( SELECT [Extent17].[Id] AS [Id], [Extent17].[RegistrationRequestGeneralOriginalId] AS [RegistrationRequestGeneralOriginalId], [Extent17].[RegistrationRequestGeneralId] AS [RegistrationRequestGeneralId], [Extent17].[SignedDate] AS [SignedDate], [Extent17].[RegistrationRequestState] AS [RegistrationRequestState], [Extent17].[EvaluationDate] AS [EvaluationDate], [Extent17].[Score] AS [Score], [Extent17].[Reason] AS [Reason], [Extent17].[Remark] AS [Remark], [Extent17].[RegistrationRequestCode] AS [RegistrationRequestCode], [Extent17].[CreatedDate] AS [CreatedDate], [Extent17].[CreatedBy] AS [CreatedBy], [Extent17].[LastModifiedDate] AS [LastModifiedDate], [Extent17].[LastModifiedBy] AS [LastModifiedBy], [Extent18].[Id] AS [Id1], [Extent18].[RegistrationRequestBusinessRelationId] AS [RegistrationRequestBusinessRelationId], [Extent18].[AuthorizedRepresentativeCompanyName] AS [AuthorizedRepresentativeCompanyName], [Extent18].[AuthorizedRepresentativeVatNumber] AS [AuthorizedRepresentativeVatNumber], [Extent18].[DeclarationPeriod] AS [DeclarationPeriod], [Extent18].[ProfileType] AS [ProfileType], [Extent18].[InternetSales] AS [InternetSales], [Extent18].[OtherThanInternetSales] AS [OtherThanInternetSales], [Extent19].[Id] AS [Id2], [Extent19].[BicAccountNumber] AS [BicAccountNumber], [Extent19].[BusinessRelationName] AS [BusinessRelationName], [Extent19].[EmailAddress] AS [EmailAddress], [Extent19].[Fax] AS [Fax], [Extent19].[FoundingDate] AS [FoundingDate], [Extent19].[IbanAccountNumber] AS [IbanAccountNumber], [Extent19].[LanguageId] AS [LanguageId], [Extent19].[FormOfGovernmentId] AS [FormOfGovernmentId], [Extent19].[Telephone] AS [Telephone], [Extent19].[VatNumber] AS [VatNumber], [Extent19].[IsVatObligated] AS [IsVatObligated], [Extent19].[BusinessRelationCode] AS [BusinessRelationCode], [Extent20].[Id] AS [Id3], [Extent20].[RegistrationRequestBusinessRelationId] AS [RegistrationRequestBusinessRelationId1], [Extent20].[AuthorizedRepresentativeCompanyName] AS [AuthorizedRepresentativeCompanyName1], [Extent20].[AuthorizedRepresentativeVatNumber] AS [AuthorizedRepresentativeVatNumber1], [Extent20].[DeclarationPeriod] AS [DeclarationPeriod1], [Extent20].[ProfileType] AS [ProfileType1], [Extent20].[InternetSales] AS [InternetSales1], [Extent20].[OtherThanInternetSales] AS [OtherThanInternetSales1], [Extent21].[Id] AS [Id4], [Extent21].[BicAccountNumber] AS [BicAccountNumber1], [Extent21].[BusinessRelationName] AS [BusinessRelationName1], [Extent21].[EmailAddress] AS [EmailAddress1], [Extent21].[Fax] AS [Fax1], [Extent21].[FoundingDate] AS [FoundingDate1], [Extent21].[IbanAccountNumber] AS [IbanAccountNumber1], [Extent21].[LanguageId] AS [LanguageId1], [Extent21].[FormOfGovernmentId] AS [FormOfGovernmentId1], [Extent21].[Telephone] AS [Telephone1], [Extent21].[VatNumber] AS [VatNumber1], [Extent21].[IsVatObligated] AS [IsVatObligated1], [Extent21].[BusinessRelationCode] AS [BusinessRelationCode1], (SELECT MIN([Extent22].[FromDate]) AS [A1] FROM [dbo].[RegistrationRequestDeclarationProfile] AS [Extent22] WHERE (([Extent22].[Deleted] = @DynamicFilterParam_000001) ) AND ([Extent17].[Id] = [Extent22].[RegistrationRequestId])) AS [C1] FROM (SELECT [Var_168].[Id] AS [Id], [Var_168].[RegistrationRequestGeneralOriginalId] AS [RegistrationRequestGeneralOriginalId], [Var_168].[RegistrationRequestGeneralId] AS [RegistrationRequestGeneralId], [Var_168].[SignedDate] AS [SignedDate], [Var_168].[RegistrationRequestState] AS [RegistrationRequestState], [Var_168].[EvaluationDate] AS [EvaluationDate], [Var_168].[Score] AS [Score], [Var_168].[Reason] AS [Reason], [Var_168].[Remark] AS [Remark], [Var_168].[RegistrationRequestCode] AS [RegistrationRequestCode], [Var_168].[CreatedDate] AS [CreatedDate], [Var_168].[CreatedBy] AS [CreatedBy], [Var_168].[LastModifiedDate] AS [LastModifiedDate], [Var_168].[LastModifiedBy] AS [LastModifiedBy] FROM [dbo].[RegistrationRequest] AS [Var_168] WHERE ([Var_168].[Deleted] = @DynamicFilterParam_000001) ) AS [Extent17] LEFT OUTER JOIN (SELECT [Var_169].[Id] AS [Id], [Var_169].[RegistrationRequestBusinessRelationId] AS [RegistrationRequestBusinessRelationId], [Var_169].[AuthorizedRepresentativeCompanyName] AS [AuthorizedRepresentativeCompanyName], [Var_169].[AuthorizedRepresentativeVatNumber] AS [AuthorizedRepresentativeVatNumber], [Var_169].[DeclarationPeriod] AS [DeclarationPeriod], [Var_169].[ProfileType] AS [ProfileType], [Var_169].[InternetSales] AS [InternetSales], [Var_169].[OtherThanInternetSales] AS [OtherThanInternetSales] FROM [dbo].[RegistrationRequestGeneral] AS [Var_169] WHERE ([Var_169].[Deleted] = @DynamicFilterParam_000001) ) AS [Extent18] ON [Extent17].[RegistrationRequestGeneralId] = [Extent18].[Id] LEFT OUTER JOIN (SELECT [Var_170].[Id] AS [Id], [Var_170].[BicAccountNumber] AS [BicAccountNumber], [Var_170].[BusinessRelationName] AS [BusinessRelationName], [Var_170].[EmailAddress] AS [EmailAddress], [Var_170].[Fax] AS [Fax], [Var_170].[FoundingDate] AS [FoundingDate], [Var_170].[IbanAccountNumber] AS [IbanAccountNumber], [Var_170].[LanguageId] AS [LanguageId], [Var_170].[FormOfGovernmentId] AS [FormOfGovernmentId], [Var_170].[Telephone] AS [Telephone], [Var_170].[VatNumber] AS [VatNumber], [Var_170].[IsVatObligated] AS [IsVatObligated], [Var_170].[BusinessRelationCode] AS [BusinessRelationCode] FROM [dbo].[RegistrationRequestBusinessRelation] AS [Var_170] WHERE ([Var_170].[Deleted] = @DynamicFilterParam_000001) ) AS [Extent19] ON [Extent18].[RegistrationRequestBusinessRelationId] = [Extent19].[Id] INNER JOIN (SELECT [Var_171].[Id] AS [Id], [Var_171].[RegistrationRequestBusinessRelationId] AS [RegistrationRequestBusinessRelationId], [Var_171].[AuthorizedRepresentativeCompanyName] AS [AuthorizedRepresentativeCompanyName], [Var_171].[AuthorizedRepresentativeVatNumber] AS [AuthorizedRepresentativeVatNumber], [Var_171].[DeclarationPeriod] AS [DeclarationPeriod], [Var_171].[ProfileType] AS [ProfileType], [Var_171].[InternetSales] AS [InternetSales], [Var_171].[OtherThanInternetSales] AS [OtherThanInternetSales] FROM [dbo].[RegistrationRequestGeneral] AS [Var_171] WHERE ([Var_171].[Deleted] = @DynamicFilterParam_000001) ) AS [Extent20] ON [Extent17].[RegistrationRequestGeneralOriginalId] = [Extent20].[Id] INNER JOIN (SELECT [Var_172].[Id] AS [Id], [Var_172].[BicAccountNumber] AS [BicAccountNumber], [Var_172].[BusinessRelationName] AS [BusinessRelationName], [Var_172].[EmailAddress] AS [EmailAddress], [Var_172].[Fax] AS [Fax], [Var_172].[FoundingDate] AS [FoundingDate], [Var_172].[IbanAccountNumber] AS [IbanAccountNumber], [Var_172].[LanguageId] AS [LanguageId], [Var_172].[FormOfGovernmentId] AS [FormOfGovernmentId], [Var_172].[Telephone] AS [Telephone], [Var_172].[VatNumber] AS [VatNumber], [Var_172].[IsVatObligated] AS [IsVatObligated], [Var_172].[BusinessRelationCode] AS [BusinessRelationCode] FROM [dbo].[RegistrationRequestBusinessRelation] AS [Var_172] WHERE ([Var_172].[Deleted] = @DynamicFilterParam_000001) ) AS [Extent21] ON [Extent20].[RegistrationRequestBusinessRelationId] = [Extent21].[Id] WHERE [Extent17].[Id] = @p__linq__0 ) AS [Project7] ) AS [Limit3] INNER JOIN (SELECT [Extent23].[Id] AS [Id5], [Extent23].[RegistrationRequestGeneralId] AS [RegistrationRequestGeneralId], [Extent23].[RegistrationRequestAddressId] AS [RegistrationRequestAddressId], [Extent23].[LocationTypeId] AS [LocationTypeId], [Extent24].[Id] AS [Id6], [Extent24].[Street1] AS [Street1], [Extent24].[Street2] AS [Street2], [Extent24].[HouseNumber] AS [HouseNumber], [Extent24].[HouseNumberAddition] AS [HouseNumberAddition], [Extent24].[PostalCode] AS [PostalCode], [Extent24].[City] AS [City], [Extent24].[CityId] AS [CityId], [Extent24].[CountryId] AS [CountryId] FROM (SELECT [Var_173].[Id] AS [Id], [Var_173].[RegistrationRequestGeneralId] AS [RegistrationRequestGeneralId], [Var_173].[RegistrationRequestAddressId] AS [RegistrationRequestAddressId], [Var_173].[LocationTypeId] AS [LocationTypeId] FROM [dbo].[RegistrationRequestGeneralAddress] AS [Var_173] WHERE ([Var_173].[Deleted] = @DynamicFilterParam_000001) ) AS [Extent23] INNER JOIN (SELECT [Var_174].[Id] AS [Id], [Var_174].[Street1] AS [Street1], [Var_174].[Street2] AS [Street2], [Var_174].[HouseNumber] AS [HouseNumber], [Var_174].[HouseNumberAddition] AS [HouseNumberAddition], [Var_174].[PostalCode] AS [PostalCode], [Var_174].[City] AS [City], [Var_174].[CityId] AS [CityId], [Var_174].[CountryId] AS [CountryId] FROM [dbo].[RegistrationRequestAddress] AS [Var_174] WHERE ([Var_174].[Deleted] = @DynamicFilterParam_000001) ) AS [Extent24] ON [Extent23].[RegistrationRequestAddressId] = [Extent24].[Id] ) AS [Join17] ON [Limit3].[RegistrationRequestGeneralId] = [Join17].[RegistrationRequestGeneralId] UNION ALL SELECT 4 AS [C1], [Limit4].[Id1] AS [Id], [Limit4].[Id2] AS [Id1], [Limit4].[Id3] AS [Id2], [Limit4].[Id4] AS [Id3], [Limit4].[Score] AS [Score], [Limit4].[RegistrationRequestCode] AS [RegistrationRequestCode], [Limit4].[SignedDate] AS [SignedDate], [Limit4].[RegistrationRequestState] AS [RegistrationRequestState], [Limit4].[EvaluationDate] AS [EvaluationDate], [Limit4].[Score] AS [Score1], [Limit4].[Reason] AS [Reason], [Limit4].[Remark] AS [Remark], [Limit4].[C1] AS [C2], [Limit4].[AuthorizedRepresentativeCompanyName] AS [AuthorizedRepresentativeCompanyName], [Limit4].[AuthorizedRepresentativeVatNumber] AS [AuthorizedRepresentativeVatNumber], [Limit4].[DeclarationPeriod] AS [DeclarationPeriod], [Limit4].[ProfileType] AS [ProfileType], [Limit4].[InternetSales] AS [InternetSales], [Limit4].[OtherThanInternetSales] AS [OtherThanInternetSales], [Limit4].[C2] AS [C3], [Limit4].[BusinessRelationCode] AS [BusinessRelationCode], [Limit4].[BicAccountNumber] AS [BicAccountNumber], [Limit4].[BusinessRelationName] AS [BusinessRelationName], [Limit4].[EmailAddress] AS [EmailAddress], [Limit4].[Fax] AS [Fax], [Limit4].[FoundingDate] AS [FoundingDate], [Limit4].[IbanAccountNumber] AS [IbanAccountNumber], [Limit4].[Telephone] AS [Telephone], [Limit4].[VatNumber] AS [VatNumber], [Limit4].[IsVatObligated] AS [IsVatObligated], [Limit4].[LanguageId] AS [LanguageId], [Limit4].[FormOfGovernmentId] AS [FormOfGovernmentId], [Limit4].[RegistrationRequestBusinessRelationId] AS [RegistrationRequestBusinessRelationId], [Limit4].[RegistrationRequestGeneralId] AS [RegistrationRequestGeneralId], [Limit4].[Score] AS [Score2], [Limit4].[AuthorizedRepresentativeCompanyName1] AS [AuthorizedRepresentativeCompanyName1], [Limit4].[AuthorizedRepresentativeVatNumber1] AS [AuthorizedRepresentativeVatNumber1], [Limit4].[DeclarationPeriod1] AS [DeclarationPeriod1], [Limit4].[ProfileType1] AS [ProfileType1], [Limit4].[InternetSales1] AS [InternetSales1], [Limit4].[OtherThanInternetSales1] AS [OtherThanInternetSales1], [Limit4].[Score] AS [Score3], [Limit4].[BusinessRelationCode1] AS [BusinessRelationCode1], [Limit4].[BicAccountNumber1] AS [BicAccountNumber1], [Limit4].[BusinessRelationName1] AS [BusinessRelationName1], [Limit4].[EmailAddress1] AS [EmailAddress1], [Limit4].[Fax1] AS [Fax1], [Limit4].[FoundingDate1] AS [FoundingDate1], [Limit4].[IbanAccountNumber1] AS [IbanAccountNumber1], [Limit4].[Telephone1] AS [Telephone1], [Limit4].[VatNumber1] AS [VatNumber1], [Limit4].[IsVatObligated1] AS [IsVatObligated1], [Limit4].[LanguageId1] AS [LanguageId1], [Limit4].[FormOfGovernmentId1] AS [FormOfGovernmentId1], [Limit4].[RegistrationRequestBusinessRelationId1] AS [RegistrationRequestBusinessRelationId1], [Limit4].[RegistrationRequestGeneralOriginalId] AS [RegistrationRequestGeneralOriginalId], [Limit4].[CreatedDate] AS [CreatedDate], [Limit4].[CreatedBy] AS [CreatedBy], [Limit4].[LastModifiedDate] AS [LastModifiedDate], [Limit4].[LastModifiedBy] AS [LastModifiedBy], [Limit4].[Id] AS [Id4], [Limit4].[C3] AS [C4], CAST(NULL AS int) AS [C5], CAST(NULL AS bit) AS [C6], CAST(NULL AS int) AS [C7], CAST(NULL AS varchar(1)) AS [C8], CAST(NULL AS varchar(1)) AS [C9], CAST(NULL AS datetime2) AS [C10], CAST(NULL AS varchar(1)) AS [C11], CAST(NULL AS datetime2) AS [C12], CAST(NULL AS varchar(1)) AS [C13], CAST(NULL AS uniqueidentifier) AS [C14], CAST(NULL AS uniqueidentifier) AS [C15], CAST(NULL AS int) AS [C16], CAST(NULL AS int) AS [C17], CAST(NULL AS int) AS [C18], CAST(NULL AS varchar(1)) AS [C19], CAST(NULL AS varchar(1)) AS [C20], CAST(NULL AS varchar(1)) AS [C21], CAST(NULL AS varchar(1)) AS [C22], CAST(NULL AS varchar(1)) AS [C23], CAST(NULL AS varchar(1)) AS [C24], CAST(NULL AS int) AS [C25], CAST(NULL AS int) AS [C26], CAST(NULL AS uniqueidentifier) AS [C27], CAST(NULL AS uniqueidentifier) AS [C28], CAST(NULL AS int) AS [C29], CAST(NULL AS int) AS [C30], CAST(NULL AS int) AS [C31], CAST(NULL AS varchar(1)) AS [C32], CAST(NULL AS varchar(1)) AS [C33], CAST(NULL AS varchar(1)) AS [C34], CAST(NULL AS varchar(1)) AS [C35], CAST(NULL AS varchar(1)) AS [C36], CAST(NULL AS varchar(1)) AS [C37], CAST(NULL AS int) AS [C38], CAST(NULL AS int) AS [C39], CAST(NULL AS uniqueidentifier) AS [C40], CAST(NULL AS uniqueidentifier) AS [C41], [Join23].[FunctionTitleId] AS [FunctionTitleId], [Join23].[FunctionTitleId] AS [FunctionTitleId1], [Join23].[FunctionTitleId] AS [FunctionTitleId2], [Join23].[FirstName] AS [FirstName], [Join23].[LastName] AS [LastName], [Join23].[EmailAddress] AS [EmailAddress2], [Join23].[Telephone1] AS [Telephone11], [Join23].[Telephone2] AS [Telephone2], [Join23].[TitleBusinessCard] AS [TitleBusinessCard], [Join23].[GenderId] AS [GenderId], [Join23].[LanguageId] AS [LanguageId2], [Join23].[RegistrationRequestContactPersonId] AS [RegistrationRequestContactPersonId], [Join23].[Id7] AS [Id5], CAST(NULL AS int) AS [C42], CAST(NULL AS int) AS [C43], CAST(NULL AS int) AS [C44], CAST(NULL AS varchar(1)) AS [C45], CAST(NULL AS varchar(1)) AS [C46], CAST(NULL AS varchar(1)) AS [C47], CAST(NULL AS varchar(1)) AS [C48], CAST(NULL AS varchar(1)) AS [C49], CAST(NULL AS varchar(1)) AS [C50], CAST(NULL AS int) AS [C51], CAST(NULL AS int) AS [C52], CAST(NULL AS uniqueidentifier) AS [C53], CAST(NULL AS uniqueidentifier) AS [C54] FROM (SELECT TOP (1) [Project10].[Id] AS [Id], [Project10].[RegistrationRequestGeneralOriginalId] AS [RegistrationRequestGeneralOriginalId], [Project10].[RegistrationRequestGeneralId] AS [RegistrationRequestGeneralId], [Project10].[SignedDate] AS [SignedDate], [Project10].[RegistrationRequestState] AS [RegistrationRequestState], [Project10].[EvaluationDate] AS [EvaluationDate], [Project10].[Score] AS [Score], [Project10].[Reason] AS [Reason], [Project10].[Remark] AS [Remark], [Project10].[RegistrationRequestCode] AS [RegistrationRequestCode], [Project10].[CreatedDate] AS [CreatedDate], [Project10].[CreatedBy] AS [CreatedBy], [Project10].[LastModifiedDate] AS [LastModifiedDate], [Project10].[LastModifiedBy] AS [LastModifiedBy], [Project10].[Id1] AS [Id1], [Project10].[RegistrationRequestBusinessRelationId] AS [RegistrationRequestBusinessRelationId], [Project10].[AuthorizedRepresentativeCompanyName] AS [AuthorizedRepresentativeCompanyName], [Project10].[AuthorizedRepresentativeVatNumber] AS [AuthorizedRepresentativeVatNumber], [Project10].[DeclarationPeriod] AS [DeclarationPeriod], [Project10].[ProfileType] AS [ProfileType], [Project10].[InternetSales] AS [InternetSales], [Project10].[OtherThanInternetSales] AS [OtherThanInternetSales], [Project10].[Id2] AS [Id2], [Project10].[BicAccountNumber] AS [BicAccountNumber], [Project10].[BusinessRelationName] AS [BusinessRelationName], [Project10].[EmailAddress] AS [EmailAddress], [Project10].[Fax] AS [Fax], [Project10].[FoundingDate] AS [FoundingDate], [Project10].[IbanAccountNumber] AS [IbanAccountNumber], [Project10].[LanguageId] AS [LanguageId], [Project10].[FormOfGovernmentId] AS [FormOfGovernmentId], [Project10].[Telephone] AS [Telephone], [Project10].[VatNumber] AS [VatNumber], [Project10].[IsVatObligated] AS [IsVatObligated], [Project10].[BusinessRelationCode] AS [BusinessRelationCode], [Project10].[Id3] AS [Id3], [Project10].[RegistrationRequestBusinessRelationId1] AS [RegistrationRequestBusinessRelationId1], [Project10].[AuthorizedRepresentativeCompanyName1] AS [AuthorizedRepresentativeCompanyName1], [Project10].[AuthorizedRepresentativeVatNumber1] AS [AuthorizedRepresentativeVatNumber1], [Project10].[DeclarationPeriod1] AS [DeclarationPeriod1], [Project10].[ProfileType1] AS [ProfileType1], [Project10].[InternetSales1] AS [InternetSales1], [Project10].[OtherThanInternetSales1] AS [OtherThanInternetSales1], [Project10].[Id4] AS [Id4], [Project10].[BicAccountNumber1] AS [BicAccountNumber1], [Project10].[BusinessRelationName1] AS [BusinessRelationName1], [Project10].[EmailAddress1] AS [EmailAddress1], [Project10].[Fax1] AS [Fax1], [Project10].[FoundingDate1] AS [FoundingDate1], [Project10].[IbanAccountNumber1] AS [IbanAccountNumber1], [Project10].[LanguageId1] AS [LanguageId1], [Project10].[FormOfGovernmentId1] AS [FormOfGovernmentId1], [Project10].[Telephone1] AS [Telephone1], [Project10].[VatNumber1] AS [VatNumber1], [Project10].[IsVatObligated1] AS [IsVatObligated1], [Project10].[BusinessRelationCode1] AS [BusinessRelationCode1], CASE WHEN ([Project10].[Id1] IS NOT NULL) THEN 1 END AS [C1], CASE WHEN ([Project10].[Id2] IS NOT NULL) THEN 1 END AS [C2], [Project10].[C1] AS [C3] FROM ( SELECT [Extent25].[Id] AS [Id], [Extent25].[RegistrationRequestGeneralOriginalId] AS [RegistrationRequestGeneralOriginalId], [Extent25].[RegistrationRequestGeneralId] AS [RegistrationRequestGeneralId], [Extent25].[SignedDate] AS [SignedDate], [Extent25].[RegistrationRequestState] AS [RegistrationRequestState], [Extent25].[EvaluationDate] AS [EvaluationDate], [Extent25].[Score] AS [Score], [Extent25].[Reason] AS [Reason], [Extent25].[Remark] AS [Remark], [Extent25].[RegistrationRequestCode] AS [RegistrationRequestCode], [Extent25].[CreatedDate] AS [CreatedDate], [Extent25].[CreatedBy] AS [CreatedBy], [Extent25].[LastModifiedDate] AS [LastModifiedDate], [Extent25].[LastModifiedBy] AS [LastModifiedBy], [Extent26].[Id] AS [Id1], [Extent26].[RegistrationRequestBusinessRelationId] AS [RegistrationRequestBusinessRelationId], [Extent26].[AuthorizedRepresentativeCompanyName] AS [AuthorizedRepresentativeCompanyName], [Extent26].[AuthorizedRepresentativeVatNumber] AS [AuthorizedRepresentativeVatNumber], [Extent26].[DeclarationPeriod] AS [DeclarationPeriod], [Extent26].[ProfileType] AS [ProfileType], [Extent26].[InternetSales] AS [InternetSales], [Extent26].[OtherThanInternetSales] AS [OtherThanInternetSales], [Extent27].[Id] AS [Id2], [Extent27].[BicAccountNumber] AS [BicAccountNumber], [Extent27].[BusinessRelationName] AS [BusinessRelationName], [Extent27].[EmailAddress] AS [EmailAddress], [Extent27].[Fax] AS [Fax], [Extent27].[FoundingDate] AS [FoundingDate], [Extent27].[IbanAccountNumber] AS [IbanAccountNumber], [Extent27].[LanguageId] AS [LanguageId], [Extent27].[FormOfGovernmentId] AS [FormOfGovernmentId], [Extent27].[Telephone] AS [Telephone], [Extent27].[VatNumber] AS [VatNumber], [Extent27].[IsVatObligated] AS [IsVatObligated], [Extent27].[BusinessRelationCode] AS [BusinessRelationCode], [Extent28].[Id] AS [Id3], [Extent28].[RegistrationRequestBusinessRelationId] AS [RegistrationRequestBusinessRelationId1], [Extent28].[AuthorizedRepresentativeCompanyName] AS [AuthorizedRepresentativeCompanyName1], [Extent28].[AuthorizedRepresentativeVatNumber] AS [AuthorizedRepresentativeVatNumber1], [Extent28].[DeclarationPeriod] AS [DeclarationPeriod1], [Extent28].[ProfileType] AS [ProfileType1], [Extent28].[InternetSales] AS [InternetSales1], [Extent28].[OtherThanInternetSales] AS [OtherThanInternetSales1], [Extent29].[Id] AS [Id4], [Extent29].[BicAccountNumber] AS [BicAccountNumber1], [Extent29].[BusinessRelationName] AS [BusinessRelationName1], [Extent29].[EmailAddress] AS [EmailAddress1], [Extent29].[Fax] AS [Fax1], [Extent29].[FoundingDate] AS [FoundingDate1], [Extent29].[IbanAccountNumber] AS [IbanAccountNumber1], [Extent29].[LanguageId] AS [LanguageId1], [Extent29].[FormOfGovernmentId] AS [FormOfGovernmentId1], [Extent29].[Telephone] AS [Telephone1], [Extent29].[VatNumber] AS [VatNumber1], [Extent29].[IsVatObligated] AS [IsVatObligated1], [Extent29].[BusinessRelationCode] AS [BusinessRelationCode1], (SELECT MIN([Extent30].[FromDate]) AS [A1] FROM [dbo].[RegistrationRequestDeclarationProfile] AS [Extent30] WHERE (([Extent30].[Deleted] = @DynamicFilterParam_000001) ) AND ([Extent25].[Id] = [Extent30].[RegistrationRequestId])) AS [C1] FROM (SELECT [Var_175].[Id] AS [Id], [Var_175].[RegistrationRequestGeneralOriginalId] AS [RegistrationRequestGeneralOriginalId], [Var_175].[RegistrationRequestGeneralId] AS [RegistrationRequestGeneralId], [Var_175].[SignedDate] AS [SignedDate], [Var_175].[RegistrationRequestState] AS [RegistrationRequestState], [Var_175].[EvaluationDate] AS [EvaluationDate], [Var_175].[Score] AS [Score], [Var_175].[Reason] AS [Reason], [Var_175].[Remark] AS [Remark], [Var_175].[RegistrationRequestCode] AS [RegistrationRequestCode], [Var_175].[CreatedDate] AS [CreatedDate], [Var_175].[CreatedBy] AS [CreatedBy], [Var_175].[LastModifiedDate] AS [LastModifiedDate], [Var_175].[LastModifiedBy] AS [LastModifiedBy] FROM [dbo].[RegistrationRequest] AS [Var_175] WHERE ([Var_175].[Deleted] = @DynamicFilterParam_000001) ) AS [Extent25] LEFT OUTER JOIN (SELECT [Var_176].[Id] AS [Id], [Var_176].[RegistrationRequestBusinessRelationId] AS [RegistrationRequestBusinessRelationId], [Var_176].[AuthorizedRepresentativeCompanyName] AS [AuthorizedRepresentativeCompanyName], [Var_176].[AuthorizedRepresentativeVatNumber] AS [AuthorizedRepresentativeVatNumber], [Var_176].[DeclarationPeriod] AS [DeclarationPeriod], [Var_176].[ProfileType] AS [ProfileType], [Var_176].[InternetSales] AS [InternetSales], [Var_176].[OtherThanInternetSales] AS [OtherThanInternetSales] FROM [dbo].[RegistrationRequestGeneral] AS [Var_176] WHERE ([Var_176].[Deleted] = @DynamicFilterParam_000001) ) AS [Extent26] ON [Extent25].[RegistrationRequestGeneralId] = [Extent26].[Id] LEFT OUTER JOIN (SELECT [Var_177].[Id] AS [Id], [Var_177].[BicAccountNumber] AS [BicAccountNumber], [Var_177].[BusinessRelationName] AS [BusinessRelationName], [Var_177].[EmailAddress] AS [EmailAddress], [Var_177].[Fax] AS [Fax], [Var_177].[FoundingDate] AS [FoundingDate], [Var_177].[IbanAccountNumber] AS [IbanAccountNumber], [Var_177].[LanguageId] AS [LanguageId], [Var_177].[FormOfGovernmentId] AS [FormOfGovernmentId], [Var_177].[Telephone] AS [Telephone], [Var_177].[VatNumber] AS [VatNumber], [Var_177].[IsVatObligated] AS [IsVatObligated], [Var_177].[BusinessRelationCode] AS [BusinessRelationCode] FROM [dbo].[RegistrationRequestBusinessRelation] AS [Var_177] WHERE ([Var_177].[Deleted] = @DynamicFilterParam_000001) ) AS [Extent27] ON [Extent26].[RegistrationRequestBusinessRelationId] = [Extent27].[Id] INNER JOIN (SELECT [Var_178].[Id] AS [Id], [Var_178].[RegistrationRequestBusinessRelationId] AS [RegistrationRequestBusinessRelationId], [Var_178].[AuthorizedRepresentativeCompanyName] AS [AuthorizedRepresentativeCompanyName], [Var_178].[AuthorizedRepresentativeVatNumber] AS [AuthorizedRepresentativeVatNumber], [Var_178].[DeclarationPeriod] AS [DeclarationPeriod], [Var_178].[ProfileType] AS [ProfileType], [Var_178].[InternetSales] AS [InternetSales], [Var_178].[OtherThanInternetSales] AS [OtherThanInternetSales] FROM [dbo].[RegistrationRequestGeneral] AS [Var_178] WHERE ([Var_178].[Deleted] = @DynamicFilterParam_000001) ) AS [Extent28] ON [Extent25].[RegistrationRequestGeneralOriginalId] = [Extent28].[Id] INNER JOIN (SELECT [Var_179].[Id] AS [Id], [Var_179].[BicAccountNumber] AS [BicAccountNumber], [Var_179].[BusinessRelationName] AS [BusinessRelationName], [Var_179].[EmailAddress] AS [EmailAddress], [Var_179].[Fax] AS [Fax], [Var_179].[FoundingDate] AS [FoundingDate], [Var_179].[IbanAccountNumber] AS [IbanAccountNumber], [Var_179].[LanguageId] AS [LanguageId], [Var_179].[FormOfGovernmentId] AS [FormOfGovernmentId], [Var_179].[Telephone] AS [Telephone], [Var_179].[VatNumber] AS [VatNumber], [Var_179].[IsVatObligated] AS [IsVatObligated], [Var_179].[BusinessRelationCode] AS [BusinessRelationCode] FROM [dbo].[RegistrationRequestBusinessRelation] AS [Var_179] WHERE ([Var_179].[Deleted] = @DynamicFilterParam_000001) ) AS [Extent29] ON [Extent28].[RegistrationRequestBusinessRelationId] = [Extent29].[Id] WHERE [Extent25].[Id] = @p__linq__0 ) AS [Project10] ) AS [Limit4] INNER JOIN (SELECT [Extent31].[Id] AS [Id7], [Extent31].[RegistrationRequestGeneralId] AS [RegistrationRequestGeneralId], [Extent31].[RegistrationRequestContactPersonId] AS [RegistrationRequestContactPersonId], [Extent31].[FunctionTitleId] AS [FunctionTitleId], [Extent32].[Id] AS [Id8], [Extent32].[FirstName] AS [FirstName], [Extent32].[LastName] AS [LastName], [Extent32].[EmailAddress] AS [EmailAddress], [Extent32].[Telephone1] AS [Telephone1], [Extent32].[Telephone2] AS [Telephone2], [Extent32].[GenderId] AS [GenderId], [Extent32].[LanguageId] AS [LanguageId], [Extent32].[TitleBusinessCard] AS [TitleBusinessCard] FROM (SELECT [Var_180].[Id] AS [Id], [Var_180].[RegistrationRequestGeneralId] AS [RegistrationRequestGeneralId], [Var_180].[RegistrationRequestContactPersonId] AS [RegistrationRequestContactPersonId], [Var_180].[FunctionTitleId] AS [FunctionTitleId] FROM [dbo].[RegistrationRequestGeneralContactPerson] AS [Var_180] WHERE ([Var_180].[Deleted] = @DynamicFilterParam_000001) ) AS [Extent31] INNER JOIN (SELECT [Var_181].[Id] AS [Id], [Var_181].[FirstName] AS [FirstName], [Var_181].[LastName] AS [LastName], [Var_181].[EmailAddress] AS [EmailAddress], [Var_181].[Telephone1] AS [Telephone1], [Var_181].[Telephone2] AS [Telephone2], [Var_181].[GenderId] AS [GenderId], [Var_181].[LanguageId] AS [LanguageId], [Var_181].[TitleBusinessCard] AS [TitleBusinessCard] FROM [dbo].[RegistrationRequestContactPerson] AS [Var_181] WHERE ([Var_181].[Deleted] = @DynamicFilterParam_000001) ) AS [Extent32] ON [Extent31].[RegistrationRequestContactPersonId] = [Extent32].[Id] ) AS [Join23] ON [Limit4].[RegistrationRequestGeneralOriginalId] = [Join23].[RegistrationRequestGeneralId] UNION ALL SELECT 5 AS [C1], [Limit5].[Id1] AS [Id], [Limit5].[Id2] AS [Id1], [Limit5].[Id3] AS [Id2], [Limit5].[Id4] AS [Id3], [Limit5].[Score] AS [Score], [Limit5].[RegistrationRequestCode] AS [RegistrationRequestCode], [Limit5].[SignedDate] AS [SignedDate], [Limit5].[RegistrationRequestState] AS [RegistrationRequestState], [Limit5].[EvaluationDate] AS [EvaluationDate], [Limit5].[Score] AS [Score1], [Limit5].[Reason] AS [Reason], [Limit5].[Remark] AS [Remark], [Limit5].[C1] AS [C2], [Limit5].[AuthorizedRepresentativeCompanyName] AS [AuthorizedRepresentativeCompanyName], [Limit5].[AuthorizedRepresentativeVatNumber] AS [AuthorizedRepresentativeVatNumber], [Limit5].[DeclarationPeriod] AS [DeclarationPeriod], [Limit5].[ProfileType] AS [ProfileType], [Limit5].[InternetSales] AS [InternetSales], [Limit5].[OtherThanInternetSales] AS [OtherThanInternetSales], [Limit5].[C2] AS [C3], [Limit5].[BusinessRelationCode] AS [BusinessRelationCode], [Limit5].[BicAccountNumber] AS [BicAccountNumber], [Limit5].[BusinessRelationName] AS [BusinessRelationName], [Limit5].[EmailAddress] AS [EmailAddress], [Limit5].[Fax] AS [Fax], [Limit5].[FoundingDate] AS [FoundingDate], [Limit5].[IbanAccountNumber] AS [IbanAccountNumber], [Limit5].[Telephone] AS [Telephone], [Limit5].[VatNumber] AS [VatNumber], [Limit5].[IsVatObligated] AS [IsVatObligated], [Limit5].[LanguageId] AS [LanguageId], [Limit5].[FormOfGovernmentId] AS [FormOfGovernmentId], [Limit5].[RegistrationRequestBusinessRelationId] AS [RegistrationRequestBusinessRelationId], [Limit5].[RegistrationRequestGeneralId] AS [RegistrationRequestGeneralId], [Limit5].[Score] AS [Score2], [Limit5].[AuthorizedRepresentativeCompanyName1] AS [AuthorizedRepresentativeCompanyName1], [Limit5].[AuthorizedRepresentativeVatNumber1] AS [AuthorizedRepresentativeVatNumber1], [Limit5].[DeclarationPeriod1] AS [DeclarationPeriod1], [Limit5].[ProfileType1] AS [ProfileType1], [Limit5].[InternetSales1] AS [InternetSales1], [Limit5].[OtherThanInternetSales1] AS [OtherThanInternetSales1], [Limit5].[Score] AS [Score3], [Limit5].[BusinessRelationCode1] AS [BusinessRelationCode1], [Limit5].[BicAccountNumber1] AS [BicAccountNumber1], [Limit5].[BusinessRelationName1] AS [BusinessRelationName1], [Limit5].[EmailAddress1] AS [EmailAddress1], [Limit5].[Fax1] AS [Fax1], [Limit5].[FoundingDate1] AS [FoundingDate1], [Limit5].[IbanAccountNumber1] AS [IbanAccountNumber1], [Limit5].[Telephone1] AS [Telephone1], [Limit5].[VatNumber1] AS [VatNumber1], [Limit5].[IsVatObligated1] AS [IsVatObligated1], [Limit5].[LanguageId1] AS [LanguageId1], [Limit5].[FormOfGovernmentId1] AS [FormOfGovernmentId1], [Limit5].[RegistrationRequestBusinessRelationId1] AS [RegistrationRequestBusinessRelationId1], [Limit5].[RegistrationRequestGeneralOriginalId] AS [RegistrationRequestGeneralOriginalId], [Limit5].[CreatedDate] AS [CreatedDate], [Limit5].[CreatedBy] AS [CreatedBy], [Limit5].[LastModifiedDate] AS [LastModifiedDate], [Limit5].[LastModifiedBy] AS [LastModifiedBy], [Limit5].[Id] AS [Id4], [Limit5].[C3] AS [C4], CAST(NULL AS int) AS [C5], CAST(NULL AS bit) AS [C6], CAST(NULL AS int) AS [C7], CAST(NULL AS varchar(1)) AS [C8], CAST(NULL AS varchar(1)) AS [C9], CAST(NULL AS datetime2) AS [C10], CAST(NULL AS varchar(1)) AS [C11], CAST(NULL AS datetime2) AS [C12], CAST(NULL AS varchar(1)) AS [C13], CAST(NULL AS uniqueidentifier) AS [C14], CAST(NULL AS uniqueidentifier) AS [C15], CAST(NULL AS int) AS [C16], CAST(NULL AS int) AS [C17], CAST(NULL AS int) AS [C18], CAST(NULL AS varchar(1)) AS [C19], CAST(NULL AS varchar(1)) AS [C20], CAST(NULL AS varchar(1)) AS [C21], CAST(NULL AS varchar(1)) AS [C22], CAST(NULL AS varchar(1)) AS [C23], CAST(NULL AS varchar(1)) AS [C24], CAST(NULL AS int) AS [C25], CAST(NULL AS int) AS [C26], CAST(NULL AS uniqueidentifier) AS [C27], CAST(NULL AS uniqueidentifier) AS [C28], CAST(NULL AS int) AS [C29], CAST(NULL AS int) AS [C30], CAST(NULL AS int) AS [C31], CAST(NULL AS varchar(1)) AS [C32], CAST(NULL AS varchar(1)) AS [C33], CAST(NULL AS varchar(1)) AS [C34], CAST(NULL AS varchar(1)) AS [C35], CAST(NULL AS varchar(1)) AS [C36], CAST(NULL AS varchar(1)) AS [C37], CAST(NULL AS int) AS [C38], CAST(NULL AS int) AS [C39], CAST(NULL AS uniqueidentifier) AS [C40], CAST(NULL AS uniqueidentifier) AS [C41], CAST(NULL AS int) AS [C42], CAST(NULL AS int) AS [C43], CAST(NULL AS int) AS [C44], CAST(NULL AS varchar(1)) AS [C45], CAST(NULL AS varchar(1)) AS [C46], CAST(NULL AS varchar(1)) AS [C47], CAST(NULL AS varchar(1)) AS [C48], CAST(NULL AS varchar(1)) AS [C49], CAST(NULL AS varchar(1)) AS [C50], CAST(NULL AS int) AS [C51], CAST(NULL AS int) AS [C52], CAST(NULL AS uniqueidentifier) AS [C53], CAST(NULL AS uniqueidentifier) AS [C54], [Join29].[LocationTypeId] AS [LocationTypeId], [Join29].[LocationTypeId] AS [LocationTypeId1], [Join29].[LocationTypeId] AS [LocationTypeId2], [Join29].[Street1] AS [Street1], [Join29].[Street2] AS [Street2], [Join29].[HouseNumber] AS [HouseNumber], [Join29].[HouseNumberAddition] AS [HouseNumberAddition], [Join29].[PostalCode] AS [PostalCode], [Join29].[City] AS [City], [Join29].[CityId] AS [CityId], [Join29].[CountryId] AS [CountryId], [Join29].[RegistrationRequestAddressId] AS [RegistrationRequestAddressId], [Join29].[Id9] AS [Id5] FROM (SELECT TOP (1) [Project13].[Id] AS [Id], [Project13].[RegistrationRequestGeneralOriginalId] AS [RegistrationRequestGeneralOriginalId], [Project13].[RegistrationRequestGeneralId] AS [RegistrationRequestGeneralId], [Project13].[SignedDate] AS [SignedDate], [Project13].[RegistrationRequestState] AS [RegistrationRequestState], [Project13].[EvaluationDate] AS [EvaluationDate], [Project13].[Score] AS [Score], [Project13].[Reason] AS [Reason], [Project13].[Remark] AS [Remark], [Project13].[RegistrationRequestCode] AS [RegistrationRequestCode], [Project13].[CreatedDate] AS [CreatedDate], [Project13].[CreatedBy] AS [CreatedBy], [Project13].[LastModifiedDate] AS [LastModifiedDate], [Project13].[LastModifiedBy] AS [LastModifiedBy], [Project13].[Id1] AS [Id1], [Project13].[RegistrationRequestBusinessRelationId] AS [RegistrationRequestBusinessRelationId], [Project13].[AuthorizedRepresentativeCompanyName] AS [AuthorizedRepresentativeCompanyName], [Project13].[AuthorizedRepresentativeVatNumber] AS [AuthorizedRepresentativeVatNumber], [Project13].[DeclarationPeriod] AS [DeclarationPeriod], [Project13].[ProfileType] AS [ProfileType], [Project13].[InternetSales] AS [InternetSales], [Project13].[OtherThanInternetSales] AS [OtherThanInternetSales], [Project13].[Id2] AS [Id2], [Project13].[BicAccountNumber] AS [BicAccountNumber], [Project13].[BusinessRelationName] AS [BusinessRelationName], [Project13].[EmailAddress] AS [EmailAddress], [Project13].[Fax] AS [Fax], [Project13].[FoundingDate] AS [FoundingDate], [Project13].[IbanAccountNumber] AS [IbanAccountNumber], [Project13].[LanguageId] AS [LanguageId], [Project13].[FormOfGovernmentId] AS [FormOfGovernmentId], [Project13].[Telephone] AS [Telephone], [Project13].[VatNumber] AS [VatNumber], [Project13].[IsVatObligated] AS [IsVatObligated], [Project13].[BusinessRelationCode] AS [BusinessRelationCode], [Project13].[Id3] AS [Id3], [Project13].[RegistrationRequestBusinessRelationId1] AS [RegistrationRequestBusinessRelationId1], [Project13].[AuthorizedRepresentativeCompanyName1] AS [AuthorizedRepresentativeCompanyName1], [Project13].[AuthorizedRepresentativeVatNumber1] AS [AuthorizedRepresentativeVatNumber1], [Project13].[DeclarationPeriod1] AS [DeclarationPeriod1], [Project13].[ProfileType1] AS [ProfileType1], [Project13].[InternetSales1] AS [InternetSales1], [Project13].[OtherThanInternetSales1] AS [OtherThanInternetSales1], [Project13].[Id4] AS [Id4], [Project13].[BicAccountNumber1] AS [BicAccountNumber1], [Project13].[BusinessRelationName1] AS [BusinessRelationName1], [Project13].[EmailAddress1] AS [EmailAddress1], [Project13].[Fax1] AS [Fax1], [Project13].[FoundingDate1] AS [FoundingDate1], [Project13].[IbanAccountNumber1] AS [IbanAccountNumber1], [Project13].[LanguageId1] AS [LanguageId1], [Project13].[FormOfGovernmentId1] AS [FormOfGovernmentId1], [Project13].[Telephone1] AS [Telephone1], [Project13].[VatNumber1] AS [VatNumber1], [Project13].[IsVatObligated1] AS [IsVatObligated1], [Project13].[BusinessRelationCode1] AS [BusinessRelationCode1], CASE WHEN ([Project13].[Id1] IS NOT NULL) THEN 1 END AS [C1], CASE WHEN ([Project13].[Id2] IS NOT NULL) THEN 1 END AS [C2], [Project13].[C1] AS [C3] FROM ( SELECT [Extent33].[Id] AS [Id], [Extent33].[RegistrationRequestGeneralOriginalId] AS [RegistrationRequestGeneralOriginalId], [Extent33].[RegistrationRequestGeneralId] AS [RegistrationRequestGeneralId], [Extent33].[SignedDate] AS [SignedDate], [Extent33].[RegistrationRequestState] AS [RegistrationRequestState], [Extent33].[EvaluationDate] AS [EvaluationDate], [Extent33].[Score] AS [Score], [Extent33].[Reason] AS [Reason], [Extent33].[Remark] AS [Remark], [Extent33].[RegistrationRequestCode] AS [RegistrationRequestCode], [Extent33].[CreatedDate] AS [CreatedDate], [Extent33].[CreatedBy] AS [CreatedBy], [Extent33].[LastModifiedDate] AS [LastModifiedDate], [Extent33].[LastModifiedBy] AS [LastModifiedBy], [Extent34].[Id] AS [Id1], [Extent34].[RegistrationRequestBusinessRelationId] AS [RegistrationRequestBusinessRelationId], [Extent34].[AuthorizedRepresentativeCompanyName] AS [AuthorizedRepresentativeCompanyName], [Extent34].[AuthorizedRepresentativeVatNumber] AS [AuthorizedRepresentativeVatNumber], [Extent34].[DeclarationPeriod] AS [DeclarationPeriod], [Extent34].[ProfileType] AS [ProfileType], [Extent34].[InternetSales] AS [InternetSales], [Extent34].[OtherThanInternetSales] AS [OtherThanInternetSales], [Extent35].[Id] AS [Id2], [Extent35].[BicAccountNumber] AS [BicAccountNumber], [Extent35].[BusinessRelationName] AS [BusinessRelationName], [Extent35].[EmailAddress] AS [EmailAddress], [Extent35].[Fax] AS [Fax], [Extent35].[FoundingDate] AS [FoundingDate], [Extent35].[IbanAccountNumber] AS [IbanAccountNumber], [Extent35].[LanguageId] AS [LanguageId], [Extent35].[FormOfGovernmentId] AS [FormOfGovernmentId], [Extent35].[Telephone] AS [Telephone], [Extent35].[VatNumber] AS [VatNumber], [Extent35].[IsVatObligated] AS [IsVatObligated], [Extent35].[BusinessRelationCode] AS [BusinessRelationCode], [Extent36].[Id] AS [Id3], [Extent36].[RegistrationRequestBusinessRelationId] AS [RegistrationRequestBusinessRelationId1], [Extent36].[AuthorizedRepresentativeCompanyName] AS [AuthorizedRepresentativeCompanyName1], [Extent36].[AuthorizedRepresentativeVatNumber] AS [AuthorizedRepresentativeVatNumber1], [Extent36].[DeclarationPeriod] AS [DeclarationPeriod1], [Extent36].[ProfileType] AS [ProfileType1], [Extent36].[InternetSales] AS [InternetSales1], [Extent36].[OtherThanInternetSales] AS [OtherThanInternetSales1], [Extent37].[Id] AS [Id4], [Extent37].[BicAccountNumber] AS [BicAccountNumber1], [Extent37].[BusinessRelationName] AS [BusinessRelationName1], [Extent37].[EmailAddress] AS [EmailAddress1], [Extent37].[Fax] AS [Fax1], [Extent37].[FoundingDate] AS [FoundingDate1], [Extent37].[IbanAccountNumber] AS [IbanAccountNumber1], [Extent37].[LanguageId] AS [LanguageId1], [Extent37].[FormOfGovernmentId] AS [FormOfGovernmentId1], [Extent37].[Telephone] AS [Telephone1], [Extent37].[VatNumber] AS [VatNumber1], [Extent37].[IsVatObligated] AS [IsVatObligated1], [Extent37].[BusinessRelationCode] AS [BusinessRelationCode1], (SELECT MIN([Extent38].[FromDate]) AS [A1] FROM [dbo].[RegistrationRequestDeclarationProfile] AS [Extent38] WHERE (([Extent38].[Deleted] = @DynamicFilterParam_000001) ) AND ([Extent33].[Id] = [Extent38].[RegistrationRequestId])) AS [C1] FROM (SELECT [Var_182].[Id] AS [Id], [Var_182].[RegistrationRequestGeneralOriginalId] AS [RegistrationRequestGeneralOriginalId], [Var_182].[RegistrationRequestGeneralId] AS [RegistrationRequestGeneralId], [Var_182].[SignedDate] AS [SignedDate], [Var_182].[RegistrationRequestState] AS [RegistrationRequestState], [Var_182].[EvaluationDate] AS [EvaluationDate], [Var_182].[Score] AS [Score], [Var_182].[Reason] AS [Reason], [Var_182].[Remark] AS [Remark], [Var_182].[RegistrationRequestCode] AS [RegistrationRequestCode], [Var_182].[CreatedDate] AS [CreatedDate], [Var_182].[CreatedBy] AS [CreatedBy], [Var_182].[LastModifiedDate] AS [LastModifiedDate], [Var_182].[LastModifiedBy] AS [LastModifiedBy] FROM [dbo].[RegistrationRequest] AS [Var_182] WHERE ([Var_182].[Deleted] = @DynamicFilterParam_000001) ) AS [Extent33] LEFT OUTER JOIN (SELECT [Var_183].[Id] AS [Id], [Var_183].[RegistrationRequestBusinessRelationId] AS [RegistrationRequestBusinessRelationId], [Var_183].[AuthorizedRepresentativeCompanyName] AS [AuthorizedRepresentativeCompanyName], [Var_183].[AuthorizedRepresentativeVatNumber] AS [AuthorizedRepresentativeVatNumber], [Var_183].[DeclarationPeriod] AS [DeclarationPeriod], [Var_183].[ProfileType] AS [ProfileType], [Var_183].[InternetSales] AS [InternetSales], [Var_183].[OtherThanInternetSales] AS [OtherThanInternetSales] FROM [dbo].[RegistrationRequestGeneral] AS [Var_183] WHERE ([Var_183].[Deleted] = @DynamicFilterParam_000001) ) AS [Extent34] ON [Extent33].[RegistrationRequestGeneralId] = [Extent34].[Id] LEFT OUTER JOIN (SELECT [Var_184].[Id] AS [Id], [Var_184].[BicAccountNumber] AS [BicAccountNumber], [Var_184].[BusinessRelationName] AS [BusinessRelationName], [Var_184].[EmailAddress] AS [EmailAddress], [Var_184].[Fax] AS [Fax], [Var_184].[FoundingDate] AS [FoundingDate], [Var_184].[IbanAccountNumber] AS [IbanAccountNumber], [Var_184].[LanguageId] AS [LanguageId], [Var_184].[FormOfGovernmentId] AS [FormOfGovernmentId], [Var_184].[Telephone] AS [Telephone], [Var_184].[VatNumber] AS [VatNumber], [Var_184].[IsVatObligated] AS [IsVatObligated], [Var_184].[BusinessRelationCode] AS [BusinessRelationCode] FROM [dbo].[RegistrationRequestBusinessRelation] AS [Var_184] WHERE ([Var_184].[Deleted] = @DynamicFilterParam_000001) ) AS [Extent35] ON [Extent34].[RegistrationRequestBusinessRelationId] = [Extent35].[Id] INNER JOIN (SELECT [Var_185].[Id] AS [Id], [Var_185].[RegistrationRequestBusinessRelationId] AS [RegistrationRequestBusinessRelationId], [Var_185].[AuthorizedRepresentativeCompanyName] AS [AuthorizedRepresentativeCompanyName], [Var_185].[AuthorizedRepresentativeVatNumber] AS [AuthorizedRepresentativeVatNumber], [Var_185].[DeclarationPeriod] AS [DeclarationPeriod], [Var_185].[ProfileType] AS [ProfileType], [Var_185].[InternetSales] AS [InternetSales], [Var_185].[OtherThanInternetSales] AS [OtherThanInternetSales] FROM [dbo].[RegistrationRequestGeneral] AS [Var_185] WHERE ([Var_185].[Deleted] = @DynamicFilterParam_000001) ) AS [Extent36] ON [Extent33].[RegistrationRequestGeneralOriginalId] = [Extent36].[Id] INNER JOIN (SELECT [Var_186].[Id] AS [Id], [Var_186].[BicAccountNumber] AS [BicAccountNumber], [Var_186].[BusinessRelationName] AS [BusinessRelationName], [Var_186].[EmailAddress] AS [EmailAddress], [Var_186].[Fax] AS [Fax], [Var_186].[FoundingDate] AS [FoundingDate], [Var_186].[IbanAccountNumber] AS [IbanAccountNumber], [Var_186].[LanguageId] AS [LanguageId], [Var_186].[FormOfGovernmentId] AS [FormOfGovernmentId], [Var_186].[Telephone] AS [Telephone], [Var_186].[VatNumber] AS [VatNumber], [Var_186].[IsVatObligated] AS [IsVatObligated], [Var_186].[BusinessRelationCode] AS [BusinessRelationCode] FROM [dbo].[RegistrationRequestBusinessRelation] AS [Var_186] WHERE ([Var_186].[Deleted] = @DynamicFilterParam_000001) ) AS [Extent37] ON [Extent36].[RegistrationRequestBusinessRelationId] = [Extent37].[Id] WHERE [Extent33].[Id] = @p__linq__0 ) AS [Project13] ) AS [Limit5] INNER JOIN (SELECT [Extent39].[Id] AS [Id9], [Extent39].[RegistrationRequestGeneralId] AS [RegistrationRequestGeneralId], [Extent39].[RegistrationRequestAddressId] AS [RegistrationRequestAddressId], [Extent39].[LocationTypeId] AS [LocationTypeId], [Extent40].[Id] AS [Id10], [Extent40].[Street1] AS [Street1], [Extent40].[Street2] AS [Street2], [Extent40].[HouseNumber] AS [HouseNumber], [Extent40].[HouseNumberAddition] AS [HouseNumberAddition], [Extent40].[PostalCode] AS [PostalCode], [Extent40].[City] AS [City], [Extent40].[CityId] AS [CityId], [Extent40].[CountryId] AS [CountryId] FROM (SELECT [Var_187].[Id] AS [Id], [Var_187].[RegistrationRequestGeneralId] AS [RegistrationRequestGeneralId], [Var_187].[RegistrationRequestAddressId] AS [RegistrationRequestAddressId], [Var_187].[LocationTypeId] AS [LocationTypeId] FROM [dbo].[RegistrationRequestGeneralAddress] AS [Var_187] WHERE ([Var_187].[Deleted] = @DynamicFilterParam_000001) ) AS [Extent39] INNER JOIN (SELECT [Var_188].[Id] AS [Id], [Var_188].[Street1] AS [Street1], [Var_188].[Street2] AS [Street2], [Var_188].[HouseNumber] AS [HouseNumber], [Var_188].[HouseNumberAddition] AS [HouseNumberAddition], [Var_188].[PostalCode] AS [PostalCode], [Var_188].[City] AS [City], [Var_188].[CityId] AS [CityId], [Var_188].[CountryId] AS [CountryId] FROM [dbo].[RegistrationRequestAddress] AS [Var_188] WHERE ([Var_188].[Deleted] = @DynamicFilterParam_000001) ) AS [Extent40] ON [Extent39].[RegistrationRequestAddressId] = [Extent40].[Id] ) AS [Join29] ON [Limit5].[RegistrationRequestGeneralOriginalId] = [Join29].[RegistrationRequestGeneralId]) AS [UnionAll4] ORDER BY [UnionAll4].[Id] ASC, [UnionAll4].[Id1] ASC, [UnionAll4].[Id2] ASC, [UnionAll4].[Id3] ASC, [UnionAll4].[Id4] ASC, [UnionAll4].[C1] ASC -- DynamicFilterParam_000001: 'False' (Type = Boolean, IsNullable = false) -- DynamicFilterParam_000002: 'null' (Type = Boolean) -- p__linq__0: '9db9564c-ebf7-4021-913f-9650aa965687' (Type = Guid, IsNullable = false) -- Executing asynchronously at 17/10/2016 09:48:36 +02:00 -- Completed in 3 ms with result: SqlDataReader