Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- SELECT
- [UnionAll3].[IsoCountryCode] AS [C1],
- [UnionAll3].[NameContentId] AS [C2],
- [UnionAll3].[Disabled] AS [C3],
- [UnionAll3].[Email] AS [C4],
- [UnionAll3].[Fax] AS [C5],
- [UnionAll3].[Id] AS [C6],
- [UnionAll3].[C4] AS [C7],
- [UnionAll3].[C5] AS [C8],
- [UnionAll3].[C6] AS [C9],
- [UnionAll3].[PostalCode] AS [C10],
- [UnionAll3].[PhoneSupport] AS [C11],
- [UnionAll3].[PhoneSales] AS [C12],
- [UnionAll3].[PhoneAfterHoursSupport] AS [C13],
- [UnionAll3].[Phone] AS [C14],
- [UnionAll3].[Preferred] AS [C15],
- [UnionAll3].[ShopOnlineImageUrl] AS [C16],
- [UnionAll3].[AdditionalInformationContentId] AS [C17],
- [UnionAll3].[AddressLine1ContentId] AS [C18],
- [UnionAll3].[AddressLine2ContentId] AS [C19],
- [UnionAll3].[CityContentId] AS [C20],
- [UnionAll3].[StateOrProvinceContentId] AS [C21],
- [UnionAll3].[NameContentId1] AS [C22],
- [UnionAll3].[HoursOfOperationContentId] AS [C23],
- [UnionAll3].[WebsiteContentId] AS [C24],
- [UnionAll3].[OnlineSellerHomePageUrlContentId] AS [C25],
- [UnionAll3].[ContactFormUrlContentId] AS [C26],
- [UnionAll3].[RequestAQuoteUrlContentId] AS [C27],
- [UnionAll3].[NameContentId2] AS [C28],
- [UnionAll3].[C1] AS [C29],
- [UnionAll3].[ContactId] AS [C30],
- [UnionAll3].[BrandId] AS [C31],
- [UnionAll3].[BrandId1] AS [C32],
- [UnionAll3].[Id1] AS [C33],
- [UnionAll3].[Name] AS [C34],
- [UnionAll3].[C7] AS [C35],
- [UnionAll3].[VALUE] AS [C36],
- [UnionAll3].[C8] AS [C37],
- [UnionAll3].[C9] AS [C38],
- [UnionAll3].[C10] AS [C39],
- [UnionAll3].[C11] AS [C40],
- [UnionAll3].[C12] AS [C41],
- [UnionAll3].[C13] AS [C42],
- [UnionAll3].[C14] AS [C43],
- [UnionAll3].[C15] AS [C44]
- FROM (SELECT
- CASE WHEN ([Join5].[ContactId] IS NULL) THEN CAST(NULL AS INT) ELSE 1 END AS [C1],
- [Limit1].[C1] AS [C2],
- [Limit1].[C4] AS [C3],
- [Limit1].[IsoCountryCode] AS [IsoCountryCode],
- [Limit1].[NameContentId] AS [NameContentId],
- [Limit1].[Disabled] AS [Disabled],
- [Limit1].[Email] AS [Email],
- [Limit1].[Fax] AS [Fax],
- [Limit1].[Id] AS [Id],
- [Limit1].[C2] AS [C4],
- [Limit1].[C3] AS [C5],
- [Limit1].[C4] AS [C6],
- [Limit1].[PostalCode] AS [PostalCode],
- [Limit1].[PhoneSupport] AS [PhoneSupport],
- [Limit1].[PhoneSales] AS [PhoneSales],
- [Limit1].[PhoneAfterHoursSupport] AS [PhoneAfterHoursSupport],
- [Limit1].[Phone] AS [Phone],
- [Limit1].[Preferred] AS [Preferred],
- [Limit1].[ShopOnlineImageUrl] AS [ShopOnlineImageUrl],
- [Limit1].[AdditionalInformationContentId] AS [AdditionalInformationContentId],
- [Limit1].[AddressLine1ContentId] AS [AddressLine1ContentId],
- [Limit1].[AddressLine2ContentId] AS [AddressLine2ContentId],
- [Limit1].[CityContentId] AS [CityContentId],
- [Limit1].[StateOrProvinceContentId] AS [StateOrProvinceContentId],
- [Limit1].[NameContentId1] AS [NameContentId1],
- [Limit1].[HoursOfOperationContentId] AS [HoursOfOperationContentId],
- [Limit1].[WebsiteContentId] AS [WebsiteContentId],
- [Limit1].[OnlineSellerHomePageUrlContentId] AS [OnlineSellerHomePageUrlContentId],
- [Limit1].[ContactFormUrlContentId] AS [ContactFormUrlContentId],
- [Limit1].[RequestAQuoteUrlContentId] AS [RequestAQuoteUrlContentId],
- [Limit1].[NameContentId] AS [NameContentId2],
- [Join5].[ContactId] AS [ContactId],
- [Join5].[BrandId1] AS [BrandId],
- [Join5].[BrandId1] AS [BrandId1],
- [Join5].[Id1] AS [Id1],
- [Join5].[Name] AS [Name],
- CASE WHEN ([Join5].[ContactId] IS NULL) THEN CAST(NULL AS INT) WHEN ([Join5].[BrandId2] IS NULL) THEN CAST(NULL AS INT) ELSE 1 END AS [C7],
- [Join5].[VALUE] AS [VALUE],
- CAST(NULL AS INT) AS [C8],
- CAST(NULL AS INT) AS [C9],
- CAST(NULL AS INT) AS [C10],
- CAST(NULL AS INT) AS [C11],
- CAST(NULL AS INT) AS [C12],
- CAST(NULL AS VARCHAR(1)) AS [C13],
- CAST(NULL AS VARCHAR(1)) AS [C14],
- CAST(NULL AS INT) AS [C15]
- FROM (SELECT [Project9].[C1] AS [C1], [Project9].[Id] AS [Id], [Project9].[Disabled] AS [Disabled], [Project9].[NameContentId] AS [NameContentId], [Project9].[AddressLine1ContentId] AS [AddressLine1ContentId], [Project9].[AddressLine2ContentId] AS [AddressLine2ContentId], [Project9].[CityContentId] AS [CityContentId], [Project9].[StateOrProvinceContentId] AS [StateOrProvinceContentId], [Project9].[HoursOfOperationContentId] AS [HoursOfOperationContentId], [Project9].[AdditionalInformationContentId] AS [AdditionalInformationContentId], [Project9].[WebsiteContentId] AS [WebsiteContentId], [Project9].[ContactFormUrlContentId] AS [ContactFormUrlContentId], [Project9].[RequestAQuoteUrlContentId] AS [RequestAQuoteUrlContentId], [Project9].[OnlineSellerHomePageUrlContentId] AS [OnlineSellerHomePageUrlContentId], [Project9].[PostalCode] AS [PostalCode], [Project9].[Email] AS [Email], [Project9].[Phone] AS [Phone], [Project9].[PhoneAfterHoursSupport] AS [PhoneAfterHoursSupport], [Project9].[PhoneSales] AS [PhoneSales], [Project9].[PhoneSupport] AS [PhoneSupport], [Project9].[Fax] AS [Fax], [Project9].[Preferred] AS [Preferred], [Project9].[ShopOnlineImageUrl] AS [ShopOnlineImageUrl], [Project9].[IsoCountryCode] AS [IsoCountryCode], [Project9].[NameContentId1] AS [NameContentId1], [Project9].[C2] AS [C2], [Project9].[C3] AS [C3], [Project9].[C4] AS [C4]
- FROM ( SELECT
- CASE WHEN ([Extent1].[Preferred] <> 1) THEN CAST(1 AS bit) WHEN ([Extent1].[Preferred] = 1) THEN CAST(0 AS bit) END AS [C1],
- [Extent1].[Id] AS [Id],
- [Extent1].[Disabled] AS [Disabled],
- [Extent1].[NameContentId] AS [NameContentId],
- [Extent1].[AddressLine1ContentId] AS [AddressLine1ContentId],
- [Extent1].[AddressLine2ContentId] AS [AddressLine2ContentId],
- [Extent1].[CityContentId] AS [CityContentId],
- [Extent1].[StateOrProvinceContentId] AS [StateOrProvinceContentId],
- [Extent1].[HoursOfOperationContentId] AS [HoursOfOperationContentId],
- [Extent1].[AdditionalInformationContentId] AS [AdditionalInformationContentId],
- [Extent1].[WebsiteContentId] AS [WebsiteContentId],
- [Extent1].[ContactFormUrlContentId] AS [ContactFormUrlContentId],
- [Extent1].[RequestAQuoteUrlContentId] AS [RequestAQuoteUrlContentId],
- [Extent1].[OnlineSellerHomePageUrlContentId] AS [OnlineSellerHomePageUrlContentId],
- [Extent1].[PostalCode] AS [PostalCode],
- [Extent1].[Email] AS [Email],
- [Extent1].[Phone] AS [Phone],
- [Extent1].[PhoneAfterHoursSupport] AS [PhoneAfterHoursSupport],
- [Extent1].[PhoneSales] AS [PhoneSales],
- [Extent1].[PhoneSupport] AS [PhoneSupport],
- [Extent1].[Fax] AS [Fax],
- [Extent1].[Preferred] AS [Preferred],
- [Extent1].[ShopOnlineImageUrl] AS [ShopOnlineImageUrl],
- [Extent2].[IsoCountryCode] AS [IsoCountryCode],
- [Extent2].[NameContentId] AS [NameContentId1],
- CASE WHEN ([Extent1].[Coordinates] IS NOT NULL) THEN [Extent1].[Coordinates].Lat ELSE CAST(0 AS FLOAT(53)) END AS [C2],
- CASE WHEN ([Extent1].[Coordinates] IS NOT NULL) THEN [Extent1].[Coordinates].Long ELSE CAST(0 AS FLOAT(53)) END AS [C3],
- CASE WHEN ((@p__linq__7 IS NOT NULL) AND ([Extent1].[Coordinates] IS NOT NULL)) THEN (@p__linq__8.STDistance([Extent1].[Coordinates])) * @p__linq__9 ELSE CAST(0 AS FLOAT(53)) END AS [C4]
- FROM [dbo].[Contact] AS [Extent1]
- LEFT OUTER JOIN [dbo].[Country] AS [Extent2] ON [Extent1].[IsoCountryCode] = [Extent2].[IsoCountryCode]
- WHERE ([Extent1].[Disabled] = @p__linq__0) AND ( EXISTS (SELECT
- 1 AS [C1]
- FROM [dbo].[ContactBrands] AS [Extent3]
- WHERE ([Extent1].[Id] = [Extent3].[ContactId]) AND ([Extent3].[BrandId] IN (57))
- )) AND ( EXISTS (SELECT
- 1 AS [C1]
- FROM [dbo].[ContactToContactType] AS [Extent4]
- WHERE ([Extent1].[Id] = [Extent4].[ContactId]) AND ([Extent4].[ContactTypeId] IN (6))
- )) AND ( EXISTS (SELECT
- 1 AS [C1]
- FROM [dbo].[ContactToContactType] AS [Extent5]
- INNER JOIN [dbo].[ContactType] AS [Extent6] ON [Extent6].[Id] = [Extent5].[ContactTypeId]
- WHERE ([Extent1].[Id] = [Extent5].[ContactId]) AND ([Extent6].[ConnectWithId] = @p__linq__1)
- )) AND ((([Extent1].[HasSpecialCoverage] <> 1) AND ((@p__linq__2.STDistance([Extent1].[Coordinates])) <= @p__linq__3)) OR ((( EXISTS (SELECT
- 1 AS [C1]
- FROM [dbo].[ContactCountiesOfCoverage] AS [Extent7]
- INNER JOIN [dbo].[County] AS [Extent8] ON [Extent8].[Id] = [Extent7].[CountyId]
- WHERE ([Extent1].[Id] = [Extent7].[ContactId]) AND (([Extent8].[Name] = @p__linq__4) OR (([Extent8].[Name] IS NULL) AND (@p__linq__4 IS NULL))) AND (([Extent8].[IsoStateCode] = @p__linq__5) OR (([Extent8].[IsoStateCode] IS NULL) AND (@p__linq__5 IS NULL)))
- )) OR ( EXISTS (SELECT
- 1 AS [C1]
- FROM [dbo].[ContactStatesOfCoverage] AS [Extent9]
- WHERE ([Extent1].[Id] = [Extent9].[ContactId]) AND ([Extent9].[IsoStateCode] = @p__linq__6)
- )) OR ( EXISTS (SELECT
- 1 AS [C1]
- FROM ( SELECT
- N'US' AS [C1]
- FROM ( SELECT 1 AS X ) AS [SingleRowTable1]
- ) AS [Project6]
- WHERE EXISTS (SELECT
- 1 AS [C1]
- FROM [dbo].[ContactCountriesOfCoverage] AS [Extent10]
- WHERE ([Extent1].[Id] = [Extent10].[ContactId]) AND ([Extent10].[IsoCountryCode] = [Project6].[C1])
- )
- ))) AND ([Extent1].[HasSpecialCoverage] = 1)))
- ) AS [Project9]
- ORDER BY ROW_NUMBER() OVER (ORDER BY [Project9].[C1] ASC, [Project9].[C4] ASC)
- OFFSET 0 ROWS FETCH NEXT 25 ROWS ONLY ) AS [Limit1]
- LEFT OUTER JOIN (SELECT [Extent11].[ContactId] AS [ContactId], [Extent11].[BrandId] AS [BrandId1], [Extent12].[Id] AS [Id1], [Extent12].[Name] AS [Name], [Extent13].[VALUE] AS [VALUE], [Extent13].[BrandId] AS [BrandId2]
- FROM [dbo].[ContactBrands] AS [Extent11]
- INNER JOIN [dbo].[Brand] AS [Extent12] ON [Extent12].[Id] = [Extent11].[BrandId]
- LEFT OUTER JOIN [dbo].[AliasEntities] AS [Extent13] ON [Extent12].[Id] = [Extent13].[BrandId] ) AS [Join5] ON [Limit1].[Id] = [Join5].[ContactId]
- UNION ALL
- SELECT
- 2 AS [C1],
- [Limit2].[C4] AS [C2],
- [Limit2].[C3] AS [C3],
- [Limit2].[IsoCountryCode] AS [IsoCountryCode],
- [Limit2].[NameContentId] AS [NameContentId],
- [Limit2].[Disabled] AS [Disabled],
- [Limit2].[Email] AS [Email],
- [Limit2].[Fax] AS [Fax],
- [Limit2].[Id] AS [Id],
- [Limit2].[C1] AS [C4],
- [Limit2].[C2] AS [C5],
- [Limit2].[C3] AS [C6],
- [Limit2].[PostalCode] AS [PostalCode],
- [Limit2].[PhoneSupport] AS [PhoneSupport],
- [Limit2].[PhoneSales] AS [PhoneSales],
- [Limit2].[PhoneAfterHoursSupport] AS [PhoneAfterHoursSupport],
- [Limit2].[Phone] AS [Phone],
- [Limit2].[Preferred] AS [Preferred],
- [Limit2].[ShopOnlineImageUrl] AS [ShopOnlineImageUrl],
- [Limit2].[AdditionalInformationContentId] AS [AdditionalInformationContentId],
- [Limit2].[AddressLine1ContentId] AS [AddressLine1ContentId],
- [Limit2].[AddressLine2ContentId] AS [AddressLine2ContentId],
- [Limit2].[CityContentId] AS [CityContentId],
- [Limit2].[StateOrProvinceContentId] AS [StateOrProvinceContentId],
- [Limit2].[NameContentId1] AS [NameContentId1],
- [Limit2].[HoursOfOperationContentId] AS [HoursOfOperationContentId],
- [Limit2].[WebsiteContentId] AS [WebsiteContentId],
- [Limit2].[OnlineSellerHomePageUrlContentId] AS [OnlineSellerHomePageUrlContentId],
- [Limit2].[ContactFormUrlContentId] AS [ContactFormUrlContentId],
- [Limit2].[RequestAQuoteUrlContentId] AS [RequestAQuoteUrlContentId],
- [Limit2].[NameContentId] AS [NameContentId2],
- CAST(NULL AS uniqueidentifier) AS [C7],
- CAST(NULL AS INT) AS [C8],
- CAST(NULL AS INT) AS [C9],
- CAST(NULL AS INT) AS [C10],
- CAST(NULL AS VARCHAR(1)) AS [C11],
- CAST(NULL AS INT) AS [C12],
- CAST(NULL AS VARCHAR(1)) AS [C13],
- [Extent24].[CategoryId] AS [CategoryId],
- [Extent24].[CategoryId] AS [CategoryId1],
- CAST(NULL AS INT) AS [C14],
- CAST(NULL AS INT) AS [C15],
- CAST(NULL AS INT) AS [C16],
- CAST(NULL AS VARCHAR(1)) AS [C17],
- CAST(NULL AS VARCHAR(1)) AS [C18],
- CAST(NULL AS INT) AS [C19]
- FROM (SELECT [Project19].[Id] AS [Id], [Project19].[Disabled] AS [Disabled], [Project19].[NameContentId] AS [NameContentId], [Project19].[AddressLine1ContentId] AS [AddressLine1ContentId], [Project19].[AddressLine2ContentId] AS [AddressLine2ContentId], [Project19].[CityContentId] AS [CityContentId], [Project19].[StateOrProvinceContentId] AS [StateOrProvinceContentId], [Project19].[HoursOfOperationContentId] AS [HoursOfOperationContentId], [Project19].[AdditionalInformationContentId] AS [AdditionalInformationContentId], [Project19].[WebsiteContentId] AS [WebsiteContentId], [Project19].[ContactFormUrlContentId] AS [ContactFormUrlContentId], [Project19].[RequestAQuoteUrlContentId] AS [RequestAQuoteUrlContentId], [Project19].[OnlineSellerHomePageUrlContentId] AS [OnlineSellerHomePageUrlContentId], [Project19].[PostalCode] AS [PostalCode], [Project19].[Email] AS [Email], [Project19].[Phone] AS [Phone], [Project19].[PhoneAfterHoursSupport] AS [PhoneAfterHoursSupport], [Project19].[PhoneSales] AS [PhoneSales], [Project19].[PhoneSupport] AS [PhoneSupport], [Project19].[Fax] AS [Fax], [Project19].[Preferred] AS [Preferred], [Project19].[ShopOnlineImageUrl] AS [ShopOnlineImageUrl], [Project19].[IsoCountryCode] AS [IsoCountryCode], [Project19].[NameContentId1] AS [NameContentId1], [Project19].[C1] AS [C1], [Project19].[C2] AS [C2], [Project19].[C3] AS [C3], [Project19].[C4] AS [C4]
- FROM ( SELECT
- [Extent14].[Id] AS [Id],
- [Extent14].[Disabled] AS [Disabled],
- [Extent14].[NameContentId] AS [NameContentId],
- [Extent14].[AddressLine1ContentId] AS [AddressLine1ContentId],
- [Extent14].[AddressLine2ContentId] AS [AddressLine2ContentId],
- [Extent14].[CityContentId] AS [CityContentId],
- [Extent14].[StateOrProvinceContentId] AS [StateOrProvinceContentId],
- [Extent14].[HoursOfOperationContentId] AS [HoursOfOperationContentId],
- [Extent14].[AdditionalInformationContentId] AS [AdditionalInformationContentId],
- [Extent14].[WebsiteContentId] AS [WebsiteContentId],
- [Extent14].[ContactFormUrlContentId] AS [ContactFormUrlContentId],
- [Extent14].[RequestAQuoteUrlContentId] AS [RequestAQuoteUrlContentId],
- [Extent14].[OnlineSellerHomePageUrlContentId] AS [OnlineSellerHomePageUrlContentId],
- [Extent14].[PostalCode] AS [PostalCode],
- [Extent14].[Email] AS [Email],
- [Extent14].[Phone] AS [Phone],
- [Extent14].[PhoneAfterHoursSupport] AS [PhoneAfterHoursSupport],
- [Extent14].[PhoneSales] AS [PhoneSales],
- [Extent14].[PhoneSupport] AS [PhoneSupport],
- [Extent14].[Fax] AS [Fax],
- [Extent14].[Preferred] AS [Preferred],
- [Extent14].[ShopOnlineImageUrl] AS [ShopOnlineImageUrl],
- [Extent15].[IsoCountryCode] AS [IsoCountryCode],
- [Extent15].[NameContentId] AS [NameContentId1],
- CASE WHEN ([Extent14].[Coordinates] IS NOT NULL) THEN [Extent14].[Coordinates].Lat ELSE CAST(0 AS FLOAT(53)) END AS [C1],
- CASE WHEN ([Extent14].[Coordinates] IS NOT NULL) THEN [Extent14].[Coordinates].Long ELSE CAST(0 AS FLOAT(53)) END AS [C2],
- CASE WHEN ((@p__linq__7 IS NOT NULL) AND ([Extent14].[Coordinates] IS NOT NULL)) THEN (@p__linq__8.STDistance([Extent14].[Coordinates])) * @p__linq__9 ELSE CAST(0 AS FLOAT(53)) END AS [C3],
- CASE WHEN ([Extent14].[Preferred] <> 1) THEN CAST(1 AS bit) WHEN ([Extent14].[Preferred] = 1) THEN CAST(0 AS bit) END AS [C4]
- FROM [dbo].[Contact] AS [Extent14]
- LEFT OUTER JOIN [dbo].[Country] AS [Extent15] ON [Extent14].[IsoCountryCode] = [Extent15].[IsoCountryCode]
- WHERE ([Extent14].[Disabled] = @p__linq__0) AND ( EXISTS (SELECT
- 1 AS [C1]
- FROM [dbo].[ContactBrands] AS [Extent16]
- WHERE ([Extent14].[Id] = [Extent16].[ContactId]) AND ([Extent16].[BrandId] IN (57))
- )) AND ( EXISTS (SELECT
- 1 AS [C1]
- FROM [dbo].[ContactToContactType] AS [Extent17]
- WHERE ([Extent14].[Id] = [Extent17].[ContactId]) AND ([Extent17].[ContactTypeId] IN (6))
- )) AND ( EXISTS (SELECT
- 1 AS [C1]
- FROM [dbo].[ContactToContactType] AS [Extent18]
- INNER JOIN [dbo].[ContactType] AS [Extent19] ON [Extent19].[Id] = [Extent18].[ContactTypeId]
- WHERE ([Extent14].[Id] = [Extent18].[ContactId]) AND ([Extent19].[ConnectWithId] = @p__linq__1)
- )) AND ((([Extent14].[HasSpecialCoverage] <> 1) AND ((@p__linq__2.STDistance([Extent14].[Coordinates])) <= @p__linq__3)) OR ((( EXISTS (SELECT
- 1 AS [C1]
- FROM [dbo].[ContactCountiesOfCoverage] AS [Extent20]
- INNER JOIN [dbo].[County] AS [Extent21] ON [Extent21].[Id] = [Extent20].[CountyId]
- WHERE ([Extent14].[Id] = [Extent20].[ContactId]) AND (([Extent21].[Name] = @p__linq__4) OR (([Extent21].[Name] IS NULL) AND (@p__linq__4 IS NULL))) AND (([Extent21].[IsoStateCode] = @p__linq__5) OR (([Extent21].[IsoStateCode] IS NULL) AND (@p__linq__5 IS NULL)))
- )) OR ( EXISTS (SELECT
- 1 AS [C1]
- FROM [dbo].[ContactStatesOfCoverage] AS [Extent22]
- WHERE ([Extent14].[Id] = [Extent22].[ContactId]) AND ([Extent22].[IsoStateCode] = @p__linq__6)
- )) OR ( EXISTS (SELECT
- 1 AS [C1]
- FROM ( SELECT
- N'US' AS [C1]
- FROM ( SELECT 1 AS X ) AS [SingleRowTable2]
- ) AS [Project16]
- WHERE EXISTS (SELECT
- 1 AS [C1]
- FROM [dbo].[ContactCountriesOfCoverage] AS [Extent23]
- WHERE ([Extent14].[Id] = [Extent23].[ContactId]) AND ([Extent23].[IsoCountryCode] = [Project16].[C1])
- )
- ))) AND ([Extent14].[HasSpecialCoverage] = 1)))
- ) AS [Project19]
- ORDER BY ROW_NUMBER() OVER (ORDER BY [Project19].[C4] ASC, [Project19].[C3] ASC)
- OFFSET 0 ROWS FETCH NEXT 25 ROWS ONLY ) AS [Limit2]
- INNER JOIN [dbo].[ContactCategories] AS [Extent24] ON [Limit2].[Id] = [Extent24].[ContactId]
- UNION ALL
- SELECT
- 3 AS [C1],
- [Limit3].[C4] AS [C2],
- [Limit3].[C3] AS [C3],
- [Limit3].[IsoCountryCode] AS [IsoCountryCode],
- [Limit3].[NameContentId] AS [NameContentId],
- [Limit3].[Disabled] AS [Disabled],
- [Limit3].[Email] AS [Email],
- [Limit3].[Fax] AS [Fax],
- [Limit3].[Id] AS [Id],
- [Limit3].[C1] AS [C4],
- [Limit3].[C2] AS [C5],
- [Limit3].[C3] AS [C6],
- [Limit3].[PostalCode] AS [PostalCode],
- [Limit3].[PhoneSupport] AS [PhoneSupport],
- [Limit3].[PhoneSales] AS [PhoneSales],
- [Limit3].[PhoneAfterHoursSupport] AS [PhoneAfterHoursSupport],
- [Limit3].[Phone] AS [Phone],
- [Limit3].[Preferred] AS [Preferred],
- [Limit3].[ShopOnlineImageUrl] AS [ShopOnlineImageUrl],
- [Limit3].[AdditionalInformationContentId] AS [AdditionalInformationContentId],
- [Limit3].[AddressLine1ContentId] AS [AddressLine1ContentId],
- [Limit3].[AddressLine2ContentId] AS [AddressLine2ContentId],
- [Limit3].[CityContentId] AS [CityContentId],
- [Limit3].[StateOrProvinceContentId] AS [StateOrProvinceContentId],
- [Limit3].[NameContentId1] AS [NameContentId1],
- [Limit3].[HoursOfOperationContentId] AS [HoursOfOperationContentId],
- [Limit3].[WebsiteContentId] AS [WebsiteContentId],
- [Limit3].[OnlineSellerHomePageUrlContentId] AS [OnlineSellerHomePageUrlContentId],
- [Limit3].[ContactFormUrlContentId] AS [ContactFormUrlContentId],
- [Limit3].[RequestAQuoteUrlContentId] AS [RequestAQuoteUrlContentId],
- [Limit3].[NameContentId] AS [NameContentId2],
- CAST(NULL AS uniqueidentifier) AS [C7],
- CAST(NULL AS INT) AS [C8],
- CAST(NULL AS INT) AS [C9],
- CAST(NULL AS INT) AS [C10],
- CAST(NULL AS VARCHAR(1)) AS [C11],
- CAST(NULL AS INT) AS [C12],
- CAST(NULL AS VARCHAR(1)) AS [C13],
- CAST(NULL AS INT) AS [C14],
- CAST(NULL AS INT) AS [C15],
- [Extent35].[ContactTypeId] AS [ContactTypeId],
- [Extent35].[ContactTypeId] AS [ContactTypeId1],
- CAST(NULL AS INT) AS [C16],
- CAST(NULL AS VARCHAR(1)) AS [C17],
- CAST(NULL AS VARCHAR(1)) AS [C18],
- CAST(NULL AS INT) AS [C19]
- FROM (SELECT [Project29].[Id] AS [Id], [Project29].[Disabled] AS [Disabled], [Project29].[NameContentId] AS [NameContentId], [Project29].[AddressLine1ContentId] AS [AddressLine1ContentId], [Project29].[AddressLine2ContentId] AS [AddressLine2ContentId], [Project29].[CityContentId] AS [CityContentId], [Project29].[StateOrProvinceContentId] AS [StateOrProvinceContentId], [Project29].[HoursOfOperationContentId] AS [HoursOfOperationContentId], [Project29].[AdditionalInformationContentId] AS [AdditionalInformationContentId], [Project29].[WebsiteContentId] AS [WebsiteContentId], [Project29].[ContactFormUrlContentId] AS [ContactFormUrlContentId], [Project29].[RequestAQuoteUrlContentId] AS [RequestAQuoteUrlContentId], [Project29].[OnlineSellerHomePageUrlContentId] AS [OnlineSellerHomePageUrlContentId], [Project29].[PostalCode] AS [PostalCode], [Project29].[Email] AS [Email], [Project29].[Phone] AS [Phone], [Project29].[PhoneAfterHoursSupport] AS [PhoneAfterHoursSupport], [Project29].[PhoneSales] AS [PhoneSales], [Project29].[PhoneSupport] AS [PhoneSupport], [Project29].[Fax] AS [Fax], [Project29].[Preferred] AS [Preferred], [Project29].[ShopOnlineImageUrl] AS [ShopOnlineImageUrl], [Project29].[IsoCountryCode] AS [IsoCountryCode], [Project29].[NameContentId1] AS [NameContentId1], [Project29].[C1] AS [C1], [Project29].[C2] AS [C2], [Project29].[C3] AS [C3], [Project29].[C4] AS [C4]
- FROM ( SELECT
- [Extent25].[Id] AS [Id],
- [Extent25].[Disabled] AS [Disabled],
- [Extent25].[NameContentId] AS [NameContentId],
- [Extent25].[AddressLine1ContentId] AS [AddressLine1ContentId],
- [Extent25].[AddressLine2ContentId] AS [AddressLine2ContentId],
- [Extent25].[CityContentId] AS [CityContentId],
- [Extent25].[StateOrProvinceContentId] AS [StateOrProvinceContentId],
- [Extent25].[HoursOfOperationContentId] AS [HoursOfOperationContentId],
- [Extent25].[AdditionalInformationContentId] AS [AdditionalInformationContentId],
- [Extent25].[WebsiteContentId] AS [WebsiteContentId],
- [Extent25].[ContactFormUrlContentId] AS [ContactFormUrlContentId],
- [Extent25].[RequestAQuoteUrlContentId] AS [RequestAQuoteUrlContentId],
- [Extent25].[OnlineSellerHomePageUrlContentId] AS [OnlineSellerHomePageUrlContentId],
- [Extent25].[PostalCode] AS [PostalCode],
- [Extent25].[Email] AS [Email],
- [Extent25].[Phone] AS [Phone],
- [Extent25].[PhoneAfterHoursSupport] AS [PhoneAfterHoursSupport],
- [Extent25].[PhoneSales] AS [PhoneSales],
- [Extent25].[PhoneSupport] AS [PhoneSupport],
- [Extent25].[Fax] AS [Fax],
- [Extent25].[Preferred] AS [Preferred],
- [Extent25].[ShopOnlineImageUrl] AS [ShopOnlineImageUrl],
- [Extent26].[IsoCountryCode] AS [IsoCountryCode],
- [Extent26].[NameContentId] AS [NameContentId1],
- CASE WHEN ([Extent25].[Coordinates] IS NOT NULL) THEN [Extent25].[Coordinates].Lat ELSE CAST(0 AS FLOAT(53)) END AS [C1],
- CASE WHEN ([Extent25].[Coordinates] IS NOT NULL) THEN [Extent25].[Coordinates].Long ELSE CAST(0 AS FLOAT(53)) END AS [C2],
- CASE WHEN ((@p__linq__7 IS NOT NULL) AND ([Extent25].[Coordinates] IS NOT NULL)) THEN (@p__linq__8.STDistance([Extent25].[Coordinates])) * @p__linq__9 ELSE CAST(0 AS FLOAT(53)) END AS [C3],
- CASE WHEN ([Extent25].[Preferred] <> 1) THEN CAST(1 AS bit) WHEN ([Extent25].[Preferred] = 1) THEN CAST(0 AS bit) END AS [C4]
- FROM [dbo].[Contact] AS [Extent25]
- LEFT OUTER JOIN [dbo].[Country] AS [Extent26] ON [Extent25].[IsoCountryCode] = [Extent26].[IsoCountryCode]
- WHERE ([Extent25].[Disabled] = @p__linq__0) AND ( EXISTS (SELECT
- 1 AS [C1]
- FROM [dbo].[ContactBrands] AS [Extent27]
- WHERE ([Extent25].[Id] = [Extent27].[ContactId]) AND ([Extent27].[BrandId] IN (57))
- )) AND ( EXISTS (SELECT
- 1 AS [C1]
- FROM [dbo].[ContactToContactType] AS [Extent28]
- WHERE ([Extent25].[Id] = [Extent28].[ContactId]) AND ([Extent28].[ContactTypeId] IN (6))
- )) AND ( EXISTS (SELECT
- 1 AS [C1]
- FROM [dbo].[ContactToContactType] AS [Extent29]
- INNER JOIN [dbo].[ContactType] AS [Extent30] ON [Extent30].[Id] = [Extent29].[ContactTypeId]
- WHERE ([Extent25].[Id] = [Extent29].[ContactId]) AND ([Extent30].[ConnectWithId] = @p__linq__1)
- )) AND ((([Extent25].[HasSpecialCoverage] <> 1) AND ((@p__linq__2.STDistance([Extent25].[Coordinates])) <= @p__linq__3)) OR ((( EXISTS (SELECT
- 1 AS [C1]
- FROM [dbo].[ContactCountiesOfCoverage] AS [Extent31]
- INNER JOIN [dbo].[County] AS [Extent32] ON [Extent32].[Id] = [Extent31].[CountyId]
- WHERE ([Extent25].[Id] = [Extent31].[ContactId]) AND (([Extent32].[Name] = @p__linq__4) OR (([Extent32].[Name] IS NULL) AND (@p__linq__4 IS NULL))) AND (([Extent32].[IsoStateCode] = @p__linq__5) OR (([Extent32].[IsoStateCode] IS NULL) AND (@p__linq__5 IS NULL)))
- )) OR ( EXISTS (SELECT
- 1 AS [C1]
- FROM [dbo].[ContactStatesOfCoverage] AS [Extent33]
- WHERE ([Extent25].[Id] = [Extent33].[ContactId]) AND ([Extent33].[IsoStateCode] = @p__linq__6)
- )) OR ( EXISTS (SELECT
- 1 AS [C1]
- FROM ( SELECT
- N'US' AS [C1]
- FROM ( SELECT 1 AS X ) AS [SingleRowTable3]
- ) AS [Project26]
- WHERE EXISTS (SELECT
- 1 AS [C1]
- FROM [dbo].[ContactCountriesOfCoverage] AS [Extent34]
- WHERE ([Extent25].[Id] = [Extent34].[ContactId]) AND ([Extent34].[IsoCountryCode] = [Project26].[C1])
- )
- ))) AND ([Extent25].[HasSpecialCoverage] = 1)))
- ) AS [Project29]
- ORDER BY ROW_NUMBER() OVER (ORDER BY [Project29].[C4] ASC, [Project29].[C3] ASC)
- OFFSET 0 ROWS FETCH NEXT 25 ROWS ONLY ) AS [Limit3]
- INNER JOIN [dbo].[ContactToContactType] AS [Extent35] ON [Limit3].[Id] = [Extent35].[ContactId]
- UNION ALL
- SELECT
- 4 AS [C1],
- [Limit4].[C4] AS [C2],
- [Limit4].[C3] AS [C3],
- [Limit4].[IsoCountryCode] AS [IsoCountryCode],
- [Limit4].[NameContentId] AS [NameContentId],
- [Limit4].[Disabled] AS [Disabled],
- [Limit4].[Email] AS [Email],
- [Limit4].[Fax] AS [Fax],
- [Limit4].[Id] AS [Id],
- [Limit4].[C1] AS [C4],
- [Limit4].[C2] AS [C5],
- [Limit4].[C3] AS [C6],
- [Limit4].[PostalCode] AS [PostalCode],
- [Limit4].[PhoneSupport] AS [PhoneSupport],
- [Limit4].[PhoneSales] AS [PhoneSales],
- [Limit4].[PhoneAfterHoursSupport] AS [PhoneAfterHoursSupport],
- [Limit4].[Phone] AS [Phone],
- [Limit4].[Preferred] AS [Preferred],
- [Limit4].[ShopOnlineImageUrl] AS [ShopOnlineImageUrl],
- [Limit4].[AdditionalInformationContentId] AS [AdditionalInformationContentId],
- [Limit4].[AddressLine1ContentId] AS [AddressLine1ContentId],
- [Limit4].[AddressLine2ContentId] AS [AddressLine2ContentId],
- [Limit4].[CityContentId] AS [CityContentId],
- [Limit4].[StateOrProvinceContentId] AS [StateOrProvinceContentId],
- [Limit4].[NameContentId1] AS [NameContentId1],
- [Limit4].[HoursOfOperationContentId] AS [HoursOfOperationContentId],
- [Limit4].[WebsiteContentId] AS [WebsiteContentId],
- [Limit4].[OnlineSellerHomePageUrlContentId] AS [OnlineSellerHomePageUrlContentId],
- [Limit4].[ContactFormUrlContentId] AS [ContactFormUrlContentId],
- [Limit4].[RequestAQuoteUrlContentId] AS [RequestAQuoteUrlContentId],
- [Limit4].[NameContentId] AS [NameContentId2],
- CAST(NULL AS uniqueidentifier) AS [C7],
- CAST(NULL AS INT) AS [C8],
- CAST(NULL AS INT) AS [C9],
- CAST(NULL AS INT) AS [C10],
- CAST(NULL AS VARCHAR(1)) AS [C11],
- CAST(NULL AS INT) AS [C12],
- CAST(NULL AS VARCHAR(1)) AS [C13],
- CAST(NULL AS INT) AS [C14],
- CAST(NULL AS INT) AS [C15],
- CAST(NULL AS INT) AS [C16],
- CAST(NULL AS INT) AS [C17],
- [Extent46].[MasterContentId] AS [MasterContentId],
- [Extent46].[VALUE] AS [VALUE],
- [Extent46].[IsoLanguageCode] AS [IsoLanguageCode],
- [Extent46].[MasterContentId] AS [MasterContentId1]
- FROM (SELECT [Project39].[Id] AS [Id], [Project39].[Disabled] AS [Disabled], [Project39].[NameContentId] AS [NameContentId], [Project39].[AddressLine1ContentId] AS [AddressLine1ContentId], [Project39].[AddressLine2ContentId] AS [AddressLine2ContentId], [Project39].[CityContentId] AS [CityContentId], [Project39].[StateOrProvinceContentId] AS [StateOrProvinceContentId], [Project39].[HoursOfOperationContentId] AS [HoursOfOperationContentId], [Project39].[AdditionalInformationContentId] AS [AdditionalInformationContentId], [Project39].[WebsiteContentId] AS [WebsiteContentId], [Project39].[ContactFormUrlContentId] AS [ContactFormUrlContentId], [Project39].[RequestAQuoteUrlContentId] AS [RequestAQuoteUrlContentId], [Project39].[OnlineSellerHomePageUrlContentId] AS [OnlineSellerHomePageUrlContentId], [Project39].[PostalCode] AS [PostalCode], [Project39].[Email] AS [Email], [Project39].[Phone] AS [Phone], [Project39].[PhoneAfterHoursSupport] AS [PhoneAfterHoursSupport], [Project39].[PhoneSales] AS [PhoneSales], [Project39].[PhoneSupport] AS [PhoneSupport], [Project39].[Fax] AS [Fax], [Project39].[Preferred] AS [Preferred], [Project39].[ShopOnlineImageUrl] AS [ShopOnlineImageUrl], [Project39].[IsoCountryCode] AS [IsoCountryCode], [Project39].[NameContentId1] AS [NameContentId1], [Project39].[C1] AS [C1], [Project39].[C2] AS [C2], [Project39].[C3] AS [C3], [Project39].[C4] AS [C4]
- FROM ( SELECT
- [Extent36].[Id] AS [Id],
- [Extent36].[Disabled] AS [Disabled],
- [Extent36].[NameContentId] AS [NameContentId],
- [Extent36].[AddressLine1ContentId] AS [AddressLine1ContentId],
- [Extent36].[AddressLine2ContentId] AS [AddressLine2ContentId],
- [Extent36].[CityContentId] AS [CityContentId],
- [Extent36].[StateOrProvinceContentId] AS [StateOrProvinceContentId],
- [Extent36].[HoursOfOperationContentId] AS [HoursOfOperationContentId],
- [Extent36].[AdditionalInformationContentId] AS [AdditionalInformationContentId],
- [Extent36].[WebsiteContentId] AS [WebsiteContentId],
- [Extent36].[ContactFormUrlContentId] AS [ContactFormUrlContentId],
- [Extent36].[RequestAQuoteUrlContentId] AS [RequestAQuoteUrlContentId],
- [Extent36].[OnlineSellerHomePageUrlContentId] AS [OnlineSellerHomePageUrlContentId],
- [Extent36].[PostalCode] AS [PostalCode],
- [Extent36].[Email] AS [Email],
- [Extent36].[Phone] AS [Phone],
- [Extent36].[PhoneAfterHoursSupport] AS [PhoneAfterHoursSupport],
- [Extent36].[PhoneSales] AS [PhoneSales],
- [Extent36].[PhoneSupport] AS [PhoneSupport],
- [Extent36].[Fax] AS [Fax],
- [Extent36].[Preferred] AS [Preferred],
- [Extent36].[ShopOnlineImageUrl] AS [ShopOnlineImageUrl],
- [Extent37].[IsoCountryCode] AS [IsoCountryCode],
- [Extent37].[NameContentId] AS [NameContentId1],
- CASE WHEN ([Extent36].[Coordinates] IS NOT NULL) THEN [Extent36].[Coordinates].Lat ELSE CAST(0 AS FLOAT(53)) END AS [C1],
- CASE WHEN ([Extent36].[Coordinates] IS NOT NULL) THEN [Extent36].[Coordinates].Long ELSE CAST(0 AS FLOAT(53)) END AS [C2],
- CASE WHEN ((@p__linq__7 IS NOT NULL) AND ([Extent36].[Coordinates] IS NOT NULL)) THEN (@p__linq__8.STDistance([Extent36].[Coordinates])) * @p__linq__9 ELSE CAST(0 AS FLOAT(53)) END AS [C3],
- CASE WHEN ([Extent36].[Preferred] <> 1) THEN CAST(1 AS bit) WHEN ([Extent36].[Preferred] = 1) THEN CAST(0 AS bit) END AS [C4]
- FROM [dbo].[Contact] AS [Extent36]
- LEFT OUTER JOIN [dbo].[Country] AS [Extent37] ON [Extent36].[IsoCountryCode] = [Extent37].[IsoCountryCode]
- WHERE ([Extent36].[Disabled] = @p__linq__0) AND ( EXISTS (SELECT
- 1 AS [C1]
- FROM [dbo].[ContactBrands] AS [Extent38]
- WHERE ([Extent36].[Id] = [Extent38].[ContactId]) AND ([Extent38].[BrandId] IN (57))
- )) AND ( EXISTS (SELECT
- 1 AS [C1]
- FROM [dbo].[ContactToContactType] AS [Extent39]
- WHERE ([Extent36].[Id] = [Extent39].[ContactId]) AND ([Extent39].[ContactTypeId] IN (6))
- )) AND ( EXISTS (SELECT
- 1 AS [C1]
- FROM [dbo].[ContactToContactType] AS [Extent40]
- INNER JOIN [dbo].[ContactType] AS [Extent41] ON [Extent41].[Id] = [Extent40].[ContactTypeId]
- WHERE ([Extent36].[Id] = [Extent40].[ContactId]) AND ([Extent41].[ConnectWithId] = @p__linq__1)
- )) AND ((([Extent36].[HasSpecialCoverage] <> 1) AND ((@p__linq__2.STDistance([Extent36].[Coordinates])) <= @p__linq__3)) OR ((( EXISTS (SELECT
- 1 AS [C1]
- FROM [dbo].[ContactCountiesOfCoverage] AS [Extent42]
- INNER JOIN [dbo].[County] AS [Extent43] ON [Extent43].[Id] = [Extent42].[CountyId]
- WHERE ([Extent36].[Id] = [Extent42].[ContactId]) AND (([Extent43].[Name] = @p__linq__4) OR (([Extent43].[Name] IS NULL) AND (@p__linq__4 IS NULL))) AND (([Extent43].[IsoStateCode] = @p__linq__5) OR (([Extent43].[IsoStateCode] IS NULL) AND (@p__linq__5 IS NULL)))
- )) OR ( EXISTS (SELECT
- 1 AS [C1]
- FROM [dbo].[ContactStatesOfCoverage] AS [Extent44]
- WHERE ([Extent36].[Id] = [Extent44].[ContactId]) AND ([Extent44].[IsoStateCode] = @p__linq__6)
- )) OR ( EXISTS (SELECT
- 1 AS [C1]
- FROM ( SELECT
- N'US' AS [C1]
- FROM ( SELECT 1 AS X ) AS [SingleRowTable4]
- ) AS [Project36]
- WHERE EXISTS (SELECT
- 1 AS [C1]
- FROM [dbo].[ContactCountriesOfCoverage] AS [Extent45]
- WHERE ([Extent36].[Id] = [Extent45].[ContactId]) AND ([Extent45].[IsoCountryCode] = [Project36].[C1])
- )
- ))) AND ([Extent36].[HasSpecialCoverage] = 1)))
- ) AS [Project39]
- ORDER BY ROW_NUMBER() OVER (ORDER BY [Project39].[C4] ASC, [Project39].[C3] ASC)
- OFFSET 0 ROWS FETCH NEXT 25 ROWS ONLY ) AS [Limit4]
- INNER JOIN [dbo].[TranslatedContent] AS [Extent46] ON ([Limit4].[NameContentId] = [Extent46].[MasterContentId]) AND ([Extent46].[IsoLanguageCode] IN (@p__linq__10,N'en'))) AS [UnionAll3]
- ORDER BY [UnionAll3].[C2] ASC, [UnionAll3].[C3] ASC, [UnionAll3].[IsoCountryCode] ASC, [UnionAll3].[Id] ASC, [UnionAll3].[C1] ASC, [UnionAll3].[ContactId] ASC, [UnionAll3].[BrandId] ASC, [UnionAll3].[Id1] ASC, [UnionAll3].[C7] ASC
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement